Bugzilla – Attachment 107747 Details for
Bug 26000
Holiday exceptions are incorrectly cached for an individual branch
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Help
|
New Account
|
Log In
[x]
|
Forgot Password
Login:
[x]
[patch]
Bug 26000: Make exception_holidays cache with branch in key
Bug-26000-Make-exceptionholidays-cache-with-branch.patch (text/plain), 4.89 KB, created by
Nick Clemens (kidclamp)
on 2020-08-04 11:54:41 UTC
(
hide
)
Description:
Bug 26000: Make exception_holidays cache with branch in key
Filename:
MIME Type:
Creator:
Nick Clemens (kidclamp)
Created:
2020-08-04 11:54:41 UTC
Size:
4.89 KB
patch
obsolete
>From e26eedf077f53c69e767df953a19b2f9699c599a Mon Sep 17 00:00:00 2001 >From: Nick Clemens <nick@bywatersolutions.com> >Date: Fri, 17 Jul 2020 11:31:29 +0000 >Subject: [PATCH] Bug 26000: Make exception_holidays cache with branch in key > >In light of 25723 offering a simpler solution here. >This would just let us avoid backporting larger changes, but this can be >marked as a duplicate if 25723 is preferred to this change >--- > C4/Calendar.pm | 14 +++++++------- > Koha/Calendar.pm | 7 ++++--- > t/Calendar.t | 2 -- > 3 files changed, 11 insertions(+), 12 deletions(-) > >diff --git a/C4/Calendar.pm b/C4/Calendar.pm >index 76c498ffaa..0d39d80ea7 100644 >--- a/C4/Calendar.pm >+++ b/C4/Calendar.pm >@@ -278,7 +278,7 @@ sub insert_single_holiday { > # changed the 'single_holidays' table, lets force/reset its cache > my $cache = Koha::Caches->get_instance(); > $cache->clear_from_cache( 'single_holidays') ; >- $cache->clear_from_cache( 'exception_holidays') ; >+ $cache->clear_from_cache( 'exception_holidays_'.$self->{branchcode}) ; > > return $self; > >@@ -323,7 +323,7 @@ sub insert_exception_holiday { > # changed the 'single_holidays' table, lets force/reset its cache > my $cache = Koha::Caches->get_instance(); > $cache->clear_from_cache( 'single_holidays') ; >- $cache->clear_from_cache( 'exception_holidays') ; >+ $cache->clear_from_cache( 'exception_holidays_'.$self->{branchcode}) ; > > return $self; > } >@@ -424,7 +424,7 @@ UPDATE special_holidays SET title = ?, description = ? > # changed the 'single_holidays' table, lets force/reset its cache > my $cache = Koha::Caches->get_instance(); > $cache->clear_from_cache( 'single_holidays') ; >- $cache->clear_from_cache( 'exception_holidays') ; >+ $cache->clear_from_cache( 'exception_holidays_'.$self->{branchcode}) ; > > return $self; > } >@@ -467,7 +467,7 @@ UPDATE special_holidays SET title = ?, description = ? > # changed the 'single_holidays' table, lets force/reset its cache > my $cache = Koha::Caches->get_instance(); > $cache->clear_from_cache( 'single_holidays') ; >- $cache->clear_from_cache( 'exception_holidays') ; >+ $cache->clear_from_cache( 'exception_holidays_'.$self->{branchcode}) ; > > return $self; > } >@@ -548,7 +548,7 @@ sub delete_holiday { > # changed the 'single_holidays' table, lets force/reset its cache > my $cache = Koha::Caches->get_instance(); > $cache->clear_from_cache( 'single_holidays') ; >- $cache->clear_from_cache( 'exception_holidays') ; >+ $cache->clear_from_cache( 'exception_holidays_'.$self->{branchcode}) ; > > return $self; > } >@@ -579,7 +579,7 @@ sub delete_holiday_range { > # changed the 'single_holidays' table, lets force/reset its cache > my $cache = Koha::Caches->get_instance(); > $cache->clear_from_cache( 'single_holidays') ; >- $cache->clear_from_cache( 'exception_holidays') ; >+ $cache->clear_from_cache( 'exception_holidays_'.$self->{branchcode}) ; > > } > >@@ -633,7 +633,7 @@ sub delete_exception_holiday_range { > # changed the 'single_holidays' table, lets force/reset its cache > my $cache = Koha::Caches->get_instance(); > $cache->clear_from_cache( 'single_holidays') ; >- $cache->clear_from_cache( 'exception_holidays') ; >+ $cache->clear_from_cache( 'exception_holidays_'.$self->{branchcode}) ; > } > > =head2 isHoliday >diff --git a/Koha/Calendar.pm b/Koha/Calendar.pm >index 31e4dc96b5..69d74f1ea0 100644 >--- a/Koha/Calendar.pm >+++ b/Koha/Calendar.pm >@@ -55,12 +55,13 @@ sub _init { > sub exception_holidays { > my ( $self ) = @_; > >+ my $branch = $self->{branchcode}; > my $cache = Koha::Caches->get_instance(); >- my $cached = $cache->get_from_cache('exception_holidays'); >+ my $key = 'exception_holidays_'.$branch; >+ my $cached = $cache->get_from_cache($key); > return $cached if $cached; > > my $dbh = C4::Context->dbh; >- my $branch = $self->{branchcode}; > my $exception_holidays_sth = $dbh->prepare( > 'SELECT day, month, year FROM special_holidays WHERE branchcode = ? AND isexception = 1' > ); >@@ -77,7 +78,7 @@ sub exception_holidays { > } > $self->{exception_holidays} = > DateTime::Set->from_datetimes( dates => $dates ); >- $cache->set_in_cache( 'exception_holidays', $self->{exception_holidays} ); >+ $cache->set_in_cache( $key, $self->{exception_holidays} ); > return $self->{exception_holidays}; > } > >diff --git a/t/Calendar.t b/t/Calendar.t >index e390696a44..9a18a85bb1 100755 >--- a/t/Calendar.t >+++ b/t/Calendar.t >@@ -78,7 +78,6 @@ fixtures_ok [ > > my $cache = Koha::Caches->get_instance(); > $cache->clear_from_cache( 'single_holidays' ) ; >-$cache->clear_from_cache( 'exception_holidays' ) ; > > # 'MPL' branch is arbitrary, is not used at all but is needed for initialization > my $cal = Koha::Calendar->new( branchcode => 'MPL' ); >@@ -336,5 +335,4 @@ subtest 'days_mode parameter' => sub { > > END { > $cache->clear_from_cache( 'single_holidays' ) ; >- $cache->clear_from_cache( 'exception_holidays' ) ; > }; >-- >2.11.0
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 26000
:
106968
|
106969
|
106987
|
107746
|
107747
|
107762
|
107763