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