Bugzilla – Attachment 106987 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: [alternate] Make exception_holidays cache with branch in key
Bug-26000-alternate-Make-exceptionholidays-cache-w.patch (text/plain), 5.46 KB, created by
Nick Clemens (kidclamp)
on 2020-07-17 11:33:05 UTC
(
hide
)
Description:
Bug 26000: [alternate] Make exception_holidays cache with branch in key
Filename:
MIME Type:
Creator:
Nick Clemens (kidclamp)
Created:
2020-07-17 11:33:05 UTC
Size:
5.46 KB
patch
obsolete
>From 865c5efd6b6628b92f01a43d77f1da154956a823 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: [alternate] 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 -- > t/db_dependent/Holidays.t | 2 +- > 4 files changed, 12 insertions(+), 13 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 0b5ac1862d..f82cd2e263 100644 >--- a/Koha/Calendar.pm >+++ b/Koha/Calendar.pm >@@ -54,12 +54,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' > ); >@@ -76,7 +77,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 b3dc02ffaf..557c6764d5 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' ); >@@ -311,5 +310,4 @@ subtest 'days_mode parameter' => sub { > > END { > $cache->clear_from_cache( 'single_holidays' ) ; >- $cache->clear_from_cache( 'exception_holidays' ) ; > }; >diff --git a/t/db_dependent/Holidays.t b/t/db_dependent/Holidays.t >index f9853ab1ea..a4b2116e2b 100755 >--- a/t/db_dependent/Holidays.t >+++ b/t/db_dependent/Holidays.t >@@ -82,7 +82,7 @@ subtest 'exception_holidays() tests' => sub { > use POSIX qw(tzset); > tzset; > >- my $calendar = Koha::Calendar->new( branchcode => $branch ); >+ $calendar = Koha::Calendar->new( branchcode => $branch ); > > C4::Calendar->new( branchcode => $branch )->insert_exception_holiday( > day => 6, >-- >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