[Patches] [PATCH] Bug 7170: Remove XML::Simple usage in favour of YAML config file

koha-patchbot at kohaaloha.com koha-patchbot at kohaaloha.com
Wed Dec 7 10:30:03 NZDT 2011


From: Ian Walls <ian.walls at bywatersolutions.com>
Date: Tue, 15 Nov 2011 12:48:43 -0500
Subject: [PATCH] Bug 7170: Remove XML::Simple usage in favour of YAML config file

Enables support for a YAML koha-conf file.
---
 C4/Context.pm |   15 +++++++++++++--
 1 files changed, 13 insertions(+), 2 deletions(-)

diff --git a/C4/Context.pm b/C4/Context.pm
index 7581faa..301ec7f 100644
--- a/C4/Context.pm
+++ b/C4/Context.pm
@@ -84,6 +84,7 @@ BEGIN {
 use DBI;
 use ZOOM;
 use XML::Simple;
+use YAML::Syck qw(LoadFile);
 use C4::Boolean;
 use C4::Debug;
 use POSIX ();
@@ -169,7 +170,7 @@ environment variable to the pathname of a configuration file to use.
 #
 # The first entry that refers to a readable file is used.
 
-use constant CONFIG_FNAME => "/etc/koha/koha-conf.xml";
+use constant CONFIG_FNAME => "/etc/koha/koha-conf.yaml";
                 # Default config file, if none is specified
                 
 my $INSTALLED_CONFIG_FNAME = '__KOHA_CONF_DIR__/koha-conf.xml';
@@ -232,6 +233,12 @@ sub read_config_file {		# Pass argument naming config file to read
     return $koha;			# Return value: ref-to-hash holding the configuration
 }
 
+sub read_yaml_config_file {
+    my $koha;
+    $koha->{'config'} = YAML::Syck::LoadFile(shift);
+    return $koha;
+}
+
 # db_scheme2dbi
 # Translates the full text name of a database into de appropiate dbi name
 # 
@@ -310,7 +317,11 @@ sub new {
         }
     }
         # Load the desired config file.
-    $self = read_config_file($conf_fname);
+    if ($conf_fname =~ /xml$/) {
+        $self = read_config_file($conf_fname);
+    } elsif ($conf_fname =~ /yaml$/) {
+        $self = read_yaml_config_file($conf_fname);
+    }
     $self->{"config_file"} = $conf_fname;
     
     warn "read_config_file($conf_fname) returned undef" if !defined($self->{"config"});
-- 
1.7.2.5


More information about the Patches mailing list