|
Lines 521-528
sub ModZebrations {
Link Here
|
| 521 |
|
521 |
|
| 522 |
=head2 _cache_preference($variable, [$value]) |
522 |
=head2 _cache_preference($variable, [$value]) |
| 523 |
|
523 |
|
| 524 |
_cache_preferences('opacusercss', $css); |
524 |
_cache_preference('opacusercss', $css); |
| 525 |
my $val = _cach_preferences('opacusercss'); |
525 |
my $val = _cache_preference('opacusercss'); |
| 526 |
|
526 |
|
| 527 |
An interface into the syspref caching. One argument to get a value, two to set |
527 |
An interface into the syspref caching. One argument to get a value, two to set |
| 528 |
it. The single argument version will return C<undef> if the cache doesn't |
528 |
it. The single argument version will return C<undef> if the cache doesn't |
|
Lines 542-547
sub _cache_preference {
Link Here
|
| 542 |
my $memcached = memcached(); |
542 |
my $memcached = memcached(); |
| 543 |
my $memcached_prefix = "_syspref_"; |
543 |
my $memcached_prefix = "_syspref_"; |
| 544 |
if ( scalar(@_) == 1 ) { |
544 |
if ( scalar(@_) == 1 ) { |
|
|
545 |
# This means we want to fetch from the cache |
| 545 |
my ($var) = @_; |
546 |
my ($var) = @_; |
| 546 |
if ($memcached) { |
547 |
if ($memcached) { |
| 547 |
my $val = $memcached->get( $memcached_prefix . lc($var) ); |
548 |
my $val = $memcached->get( $memcached_prefix . lc($var) ); |
|
Lines 557-562
sub _cache_preference {
Link Here
|
| 557 |
} |
558 |
} |
| 558 |
} |
559 |
} |
| 559 |
elsif ( scalar(@_) == 2 ) { |
560 |
elsif ( scalar(@_) == 2 ) { |
|
|
561 |
# Set something in the cache |
| 560 |
my ( $var, $val ) = @_; |
562 |
my ( $var, $val ) = @_; |
| 561 |
if ($memcached) { |
563 |
if ($memcached) { |
| 562 |
if ( !defined($val) ) { |
564 |
if ( !defined($val) ) { |
|
Lines 573-578
sub _cache_preference {
Link Here
|
| 573 |
} |
575 |
} |
| 574 |
$syspref_cache{ lc $var } = [ time, $val ]; |
576 |
$syspref_cache{ lc $var } = [ time, $val ]; |
| 575 |
} |
577 |
} |
|
|
578 |
} else { |
| 579 |
confess "Invalid arguments to _cache_preference: " . join(', ', @_); |
| 576 |
} |
580 |
} |
| 577 |
} |
581 |
} |
| 578 |
|
582 |
|
|
Lines 741-749
sub delete_preference {
Link Here
|
| 741 |
my $sth = $dbh->prepare("DELETE FROM systempreferences WHERE variable=?"); |
745 |
my $sth = $dbh->prepare("DELETE FROM systempreferences WHERE variable=?"); |
| 742 |
my $res = $sth->execute($var); |
746 |
my $res = $sth->execute($var); |
| 743 |
if ($res) { |
747 |
if ($res) { |
| 744 |
C4::Context->set_preference($var, undef); |
748 |
_cache_preference($var, undef); |
| 745 |
logaction( 'SYSTEMPREFERENCE', 'DELETE', undef, |
749 |
logaction( 'SYSTEMPREFERENCE', 'DELETE', undef, |
| 746 |
$var . " | " . ( $var // 'undefined' ) ); |
750 |
$var . " | " . ( $val // 'undefined' ) ); |
| 747 |
return 1; |
751 |
return 1; |
| 748 |
} |
752 |
} |
| 749 |
warn "Unable to delete syspref: " . $sth->errstr; |
753 |
warn "Unable to delete syspref: " . $sth->errstr; |