Bug 10325: (follow-up) restore case-insensivity of syspref cache
authorGalen Charlton <gmc@esilibrary.com>
Sun, 8 Sep 2013 05:08:51 +0000 (05:08 +0000)
committerGalen Charlton <gmc@esilibrary.com>
Sun, 8 Sep 2013 05:08:51 +0000 (05:08 +0000)
Case-insensitivity of the system preference cache was introduced in
the patch for bug 6132.  This patch corrects some breakage that
occurred.  Longer-term, IMO a hard look needs to be taken at
using a case-insensitive collation for syspref codes, and coded
values in general.

Signed-off-by: Galen Charlton <gmc@esilibrary.com>
C4/Context.pm

index 7bc7097..739a0ec 100644 (file)
@@ -542,8 +542,8 @@ sub preference {
     my $self = shift;
     my $var  = shift;    # The system preference to return
 
-    if ($use_syspref_cache && exists $sysprefs{$var}) {
-        return $sysprefs{$var};
+    if ($use_syspref_cache && exists $sysprefs{lc $var}) {
+        return $sysprefs{lc $var};
     }
 
     my $dbh  = C4::Context->dbh or return 0;
@@ -559,10 +559,10 @@ sub preference {
             WHERE   variable = ?
             LIMIT   1
         };
-        $value = $dbh->selectrow_array( $sql, {}, $var );
+        $value = $dbh->selectrow_array( $sql, {}, lc $var );
     }
 
-    $sysprefs{$var} = $value;
+    $sysprefs{lc $var} = $value;
     return $value;
 }