Bug 16520: Initialize the sysprefs Koha::Caches on demand
authorJesse Weaver <jweaver@bywatersolutions.com>
Fri, 13 May 2016 22:39:08 +0000 (16:39 -0600)
committerKyle M Hall <kyle@bywatersolutions.com>
Tue, 11 Oct 2016 12:37:16 +0000 (12:37 +0000)
Signed-off-by: Tomas Cohen Arazi <tomascohen@theke.io>
Signed-off-by: Kyle M Hall <kyle@bywatersolutions.com>
C4/Context.pm

index 5f49bbe..1866b1d 100644 (file)
@@ -407,15 +407,16 @@ sub preference {
     my $self = shift;
     my $var  = shift;    # The system preference to return
 
-    $var = lc $var;
-
     return $ENV{"OVERRIDE_SYSPREF_$var"}
         if defined $ENV{"OVERRIDE_SYSPREF_$var"};
 
-    my $cached_var = $use_syspref_cache
-        ? $syspref_cache->get_from_cache("syspref_$var")
-        : undef;
-    return $cached_var if defined $cached_var;
+    $var = lc $var;
+
+    if ($use_syspref_cache) {
+        $syspref_cache = Koha::Cache->get_instance() unless $syspref_cache;
+        my $cached_var = $syspref_cache->get_from_cache("syspref_$var");
+        return $cached_var if defined $cached_var;
+    }
 
     my $syspref;
     eval { $syspref = Koha::Config::SysPrefs->find( lc $var ) };