Bug 16068: Do not cache overridden prefs
authorJonathan Druart <jonathan.druart@bugs.koha-community.org>
Tue, 15 Mar 2016 09:38:20 +0000 (09:38 +0000)
committerBrendan A Gallagher <brendan@bywatersolutions.com>
Fri, 1 Apr 2016 19:19:31 +0000 (19:19 +0000)
These prefs do not need to be cached, a quick access to $ENV permit to
get the value.

Signed-off-by: Jacek Ablewicz <abl@biblos.pk.edu.pl>
Signed-off-by: Martin Renvoize <martin.renvoize@ptfs-europe.com>
Signed-off-by: Brendan A Gallagher <brendan@bywatersolutions.com>
C4/Context.pm

index 6b70b60..c80647a 100644 (file)
@@ -520,19 +520,17 @@ sub preference {
 
     $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;
 
-    my $value;
-    if ( defined $ENV{"OVERRIDE_SYSPREF_$var"} ) {
-        $value = $ENV{"OVERRIDE_SYSPREF_$var"};
-    } else {
-        my $syspref;
-        eval { $syspref = Koha::Config::SysPrefs->find( lc $var ) };
-        $value = $syspref ? $syspref->value() : undef;
-    }
+    my $syspref;
+    eval { $syspref = Koha::Config::SysPrefs->find( lc $var ) };
+    my $value = $syspref ? $syspref->value() : undef;
 
     if ( $use_syspref_cache ) {
         $syspref_cache->set_in_cache("syspref_$var", $value);