Bugzilla – Attachment 32873 Details for
Bug 11998
Syspref caching issues
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Help
|
New Account
|
Log In
[x]
|
Forgot Password
Login:
[x]
[patch]
Bug 11998 - add test case, fix issue found
Bug-11998---add-test-case-fix-issue-found.patch (text/plain), 3.42 KB, created by
Brendan Gallagher
on 2014-10-28 21:45:43 UTC
(
hide
)
Description:
Bug 11998 - add test case, fix issue found
Filename:
MIME Type:
Creator:
Brendan Gallagher
Created:
2014-10-28 21:45:43 UTC
Size:
3.42 KB
patch
obsolete
>From b2f7ce1bd7ed0cbf51a0f869edb97cfba382de85 Mon Sep 17 00:00:00 2001 >From: Robin Sheat <robin@catalyst.net.nz> >Date: Tue, 1 Apr 2014 17:18:22 +1300 >Subject: [PATCH] Bug 11998 - add test case, fix issue found > >Adds a test case with improved coverage of the caching functionality. >Fixes a bug that was uncovered by writing the test case. > >Signed-off-by: Brendan Gallagher <brendan@bywatersolutions.com> >--- > C4/Context.pm | 12 ++++++++---- > t/db_dependent/sysprefs.t | 13 ++++++++++++- > 2 files changed, 20 insertions(+), 5 deletions(-) > >diff --git a/C4/Context.pm b/C4/Context.pm >index 301e22a..a37c90e 100644 >--- a/C4/Context.pm >+++ b/C4/Context.pm >@@ -520,8 +520,8 @@ sub ModZebrations { > > =head2 _cache_preference($variable, [$value]) > >- _cache_preferences('opacusercss', $css); >- my $val = _cach_preferences('opacusercss'); >+ _cache_preference('opacusercss', $css); >+ my $val = _cache_preference('opacusercss'); > > An interface into the syspref caching. One argument to get a value, two to set > it. The single argument version will return C<undef> if the cache doesn't >@@ -541,6 +541,7 @@ sub _cache_preference { > my $memcached = memcached(); > my $memcached_prefix = "_syspref_"; > if ( scalar(@_) == 1 ) { >+ # This means we want to fetch from the cache > my ($var) = @_; > if ($memcached) { > my $val = $memcached->get( $memcached_prefix . lc($var) ); >@@ -556,6 +557,7 @@ sub _cache_preference { > } > } > elsif ( scalar(@_) == 2 ) { >+ # Set something in the cache > my ( $var, $val ) = @_; > if ($memcached) { > if ( !defined($val) ) { >@@ -572,6 +574,8 @@ sub _cache_preference { > } > $syspref_cache{ lc $var } = [ time, $val ]; > } >+ } else { >+ confess "Invalid arguments to _cache_preference: " . join(', ', @_); > } > } > >@@ -740,9 +744,9 @@ sub delete_preference { > my $sth = $dbh->prepare("DELETE FROM systempreferences WHERE variable=?"); > my $res = $sth->execute($var); > if ($res) { >- C4::Context->set_preference($var, undef); >+ _cache_preference($var, undef); > logaction( 'SYSTEMPREFERENCE', 'DELETE', undef, >- $var . " | " . ( $var // 'undefined' ) ); >+ $var . " | " . ( $val // 'undefined' ) ); > return 1; > } > warn "Unable to delete syspref: " . $sth->errstr; >diff --git a/t/db_dependent/sysprefs.t b/t/db_dependent/sysprefs.t >index ca88740..a2ce98e 100755 >--- a/t/db_dependent/sysprefs.t >+++ b/t/db_dependent/sysprefs.t >@@ -19,7 +19,7 @@ > # along with Koha; if not, see <http://www.gnu.org/licenses>. > > use Modern::Perl; >-use Test::More tests => 3; >+use Test::More tests => 6; > use C4::Context; > > # Start transaction >@@ -43,4 +43,15 @@ is(C4::Context->preference('opacheader'), > 'system preference value overridden from environment' > ); > >+C4::Context->set_preference('testpreference', 'abc'); >+C4::Context->delete_preference('testpreference'); >+is(C4::Context->preference('testpreference'), undef, 'deleting preferences'); >+ >+C4::Context->set_preference('testpreference', 'def'); >+# Delete from the database, it should still be in cache >+$dbh->do("DELETE FROM systempreferences WHERE variable='testpreference'"); >+is(C4::Context->preference('testpreference'), 'def', 'caching preferences'); >+C4::Context->clear_syspref_cache(); >+is(C4::Context->preference('testpreference'), undef, 'clearing preference cache'); >+ > $dbh->rollback; >-- >1.7.10.4
You cannot view the attachment while viewing its details because your browser does not support IFRAMEs.
View the attachment on a separate page
.
View Attachment As Diff
View Attachment As Raw
Actions:
View
|
Diff
|
Splinter Review
Attachments on
bug 11998
:
26575
|
26621
|
26714
|
26716
|
26717
|
27382
|
31801
|
31802
|
32870
|
32871
|
32872
|
32873
|
32874
|
33183
|
33447
|
33670
|
33671
|
33685
|
33724
|
33725
|
33746
|
33829
|
33940
|
36523
|
36524
|
36525
|
36526
|
36527
|
36528
|
36529
|
36530
|
36531
|
36532
|
36533
|
36534
|
36571
|
36583
|
36584
|
36585
|
36586
|
36587
|
36588
|
36589
|
36590
|
36591
|
36592
|
36593
|
36594
|
36595
|
48640
|
48652
|
48655
|
48687
|
48688
|
48727
|
48758
|
48928
|
48929
|
48930
|
48931
|
48932
|
48933
|
48934
|
48935
|
48936
|
48961
|
49022
|
49023
|
49024
|
49025
|
49026
|
49027
|
49028
|
49029
|
49030
|
49100
|
49101
|
49102
|
49103
|
49104
|
49105
|
49106
|
49107
|
49108