+ unless (defined $sysprefs) {
+ unless ($cache) {
+ $cache = Koha::Cache->new();
+ }
+ $sysprefs = $cache->create_hash(
+ {
+ 'key' => 'syspref',
+ 'allowupdate' => 1,
+ 'cache_type' => $use_syspref_cache ? '' : 'null',
+ 'preload' => sub {
+ my $dbh = C4::Context->dbh or return {};
+ my $vars = $dbh->selectall_arrayref("SELECT variable, value FROM systempreferences");
+ my %sysprefs = ();
+ foreach my $row (@$vars) {
+ $sysprefs{$row->[0]} = $row->[1];
+ }
+ return \%sysprefs;
+ },
+ 'constructor' => sub {
+
+ # Look up systempreferences.variable==$var
+ my $var = pop;
+ my $sysprefs = pop || {};
+ my $dbh = C4::Context->dbh or return 0;
+ my $sql =
+"SELECT value FROM systempreferences WHERE variable=? LIMIT 1";
+ $ENV{DEBUG} && carp "Retrieving syspref $var from database";
+ my $sth = $dbh->prepare_cached($sql);
+ $sth->execute($var);
+ my $res = $sth->fetchrow_hashref;
+ if ($res && $res->{'value'}) {
+ $sysprefs->{$var} = $res->{'value'};
+ } else {
+ $sysprefs->{$var} = '';
+ }
+ return $sysprefs;
+ },
+ }
+ );