Bugzilla – Attachment 107019 Details for
Bug 25723
Improve efficiency of holiday calculation
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Help
|
New Account
|
Log In
[x]
|
Forgot Password
Login:
[x]
[patch]
Bug 25723: Update cache flushing calls
Bug-25723-Update-cache-flushing-calls.patch (text/plain), 6.80 KB, created by
Joonas Kylmälä
on 2020-07-17 14:42:38 UTC
(
hide
)
Description:
Bug 25723: Update cache flushing calls
Filename:
MIME Type:
Creator:
Joonas Kylmälä
Created:
2020-07-17 14:42:38 UTC
Size:
6.80 KB
patch
obsolete
>From 14285388d58568ebad6d07c7bbe4273c9734348a Mon Sep 17 00:00:00 2001 >From: Martin Renvoize <martin.renvoize@ptfs-europe.com> >Date: Wed, 17 Jun 2020 13:18:24 +0100 >Subject: [PATCH] Bug 25723: Update cache flushing calls >MIME-Version: 1.0 >Content-Type: text/plain; charset=UTF-8 >Content-Transfer-Encoding: 8bit > >This patch updates the previous single_holidays and exeption_holidays >cache flushing calls to match the new cache key structure of the updated >routines. > >Signed-off-by: Emma Perks <Emma.Perks2@uhb.nhs.uk> >Signed-off-by: Nick Clemens <nick@bywatersolutions.com> >Signed-off-by: Joonas Kylmälä <joonas.kylmala@helsinki.fi> >--- > C4/Calendar.pm | 28 ++++++++++++++-------------- > t/Calendar.t | 8 ++++---- > t/db_dependent/Circulation.t | 12 ++++++++++-- > t/db_dependent/Circulation/CalcDateDue.t | 8 ++++---- > tools/newHolidays.pl | 3 --- > 5 files changed, 32 insertions(+), 27 deletions(-) > >diff --git a/C4/Calendar.pm b/C4/Calendar.pm >index 76c498ffaa..7b94537ccf 100644 >--- a/C4/Calendar.pm >+++ b/C4/Calendar.pm >@@ -277,8 +277,8 @@ 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') ; >+ my $key = $self->{branchcode} . "_holidays"; >+ $cache->clear_from_cache($key); > > return $self; > >@@ -322,8 +322,8 @@ 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') ; >+ my $key = $self->{branchcode} . "_holidays"; >+ $cache->clear_from_cache($key); > > return $self; > } >@@ -423,8 +423,8 @@ 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') ; >+ my $key = $self->{branchcode} . "_holidays"; >+ $cache->clear_from_cache($key); > > return $self; > } >@@ -466,8 +466,8 @@ 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') ; >+ my $key = $self->{branchcode} . "_holidays"; >+ $cache->clear_from_cache($key); > > return $self; > } >@@ -547,8 +547,8 @@ 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') ; >+ my $key = $self->{branchcode} . "_holidays"; >+ $cache->clear_from_cache($key); > > return $self; > } >@@ -578,8 +578,8 @@ 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') ; >+ my $key = $self->{branchcode} . "_holidays"; >+ $cache->clear_from_cache($key); > > } > >@@ -632,8 +632,8 @@ 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') ; >+ my $key = $self->{branchcode} . "_holidays"; >+ $cache->clear_from_cache($key); > } > > =head2 isHoliday >diff --git a/t/Calendar.t b/t/Calendar.t >index b3dc02ffaf..8657bc4999 100755 >--- a/t/Calendar.t >+++ b/t/Calendar.t >@@ -77,8 +77,8 @@ fixtures_ok [ > ], "add fixtures"; > > my $cache = Koha::Caches->get_instance(); >-$cache->clear_from_cache( 'single_holidays' ) ; >-$cache->clear_from_cache( 'exception_holidays' ) ; >+$cache->clear_from_cache('MPL_holidays'); >+$cache->clear_from_cache('CPL_holidays'); > > # 'MPL' branch is arbitrary, is not used at all but is needed for initialization > my $cal = Koha::Calendar->new( branchcode => 'MPL' ); >@@ -310,6 +310,6 @@ subtest 'days_mode parameter' => sub { > }; > > END { >- $cache->clear_from_cache( 'single_holidays' ) ; >- $cache->clear_from_cache( 'exception_holidays' ) ; >+ $cache->clear_from_cache('MPL_holidays'); >+ $cache->clear_from_cache('CPL_holidays'); > }; >diff --git a/t/db_dependent/Circulation.t b/t/db_dependent/Circulation.t >index e9f28b55d9..ac6f1e45ad 100755 >--- a/t/db_dependent/Circulation.t >+++ b/t/db_dependent/Circulation.t >@@ -110,7 +110,11 @@ $mocked_datetime->mock( 'now', sub { return $now_value->clone; } ); > my $cache = Koha::Caches->get_instance(); > $dbh->do(q|DELETE FROM special_holidays|); > $dbh->do(q|DELETE FROM repeatable_holidays|); >-$cache->clear_from_cache('single_holidays'); >+my $branches = Koha::Libraries->search(); >+for my $branch ( $branches->next ) { >+ my $key = $branch->branchcode . "_holidays"; >+ $cache->clear_from_cache($key); >+} > > # Start with a clean slate > $dbh->do('DELETE FROM issues'); >@@ -3928,4 +3932,8 @@ subtest 'Filling a hold should cancel existing transfer' => sub { > > $schema->storage->txn_rollback; > C4::Context->clear_syspref_cache(); >-$cache->clear_from_cache('single_holidays'); >+$branches = Koha::Libraries->search(); >+for my $branch ( $branches->next ) { >+ my $key = $branch->branchcode . "_holidays"; >+ $cache->clear_from_cache($key); >+} >diff --git a/t/db_dependent/Circulation/CalcDateDue.t b/t/db_dependent/Circulation/CalcDateDue.t >index 4c0999ef0d..8085dbd486 100644 >--- a/t/db_dependent/Circulation/CalcDateDue.t >+++ b/t/db_dependent/Circulation/CalcDateDue.t >@@ -43,8 +43,9 @@ Koha::CirculationRules->set_rules( > t::lib::Mocks::mock_preference('ReturnBeforeExpiry', 1); > t::lib::Mocks::mock_preference('useDaysMode', 'Days'); > >-my $cache = Koha::Caches->get_instance(); >-$cache->clear_from_cache('single_holidays'); >+my $cache = Koha::Caches->get_instance(); >+my $key = $branchcode . "_holidays"; >+$cache->clear_from_cache($key); > > my $dateexpiry = '2013-01-01'; > >@@ -302,6 +303,5 @@ $calendar->delete_holiday( > weekday => 6 > ); > >- >-$cache->clear_from_cache('single_holidays'); >+$cache->clear_from_cache($key); > $schema->storage->txn_rollback; >diff --git a/tools/newHolidays.pl b/tools/newHolidays.pl >index f13e52447b..f7a1929423 100755 >--- a/tools/newHolidays.pl >+++ b/tools/newHolidays.pl >@@ -143,7 +143,4 @@ sub add_holiday { > } > } > } >- # we updated the single_holidays table, so wipe its cache >- my $cache = Koha::Caches->get_instance(); >- $cache->clear_from_cache( 'single_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 25723
:
105789
|
105792
|
105793
|
105830
|
105831
|
105832
|
105833
|
105834
|
105835
|
105836
|
105936
|
105937
|
105939
|
105941
|
105947
|
105954
|
105955
|
105956
|
105957
|
105958
|
105959
|
105960
|
105961
|
105962
|
105963
|
105964
|
105965
|
105966
|
105967
|
105968
|
105969
|
105970
|
106991
|
106992
|
106993
|
106994
|
106995
|
106996
|
106997
|
106998
|
106999
|
107000
|
107001
|
107002
|
107003
|
107004
|
107005
|
107006
|
107007
|
107008
|
107009
|
107010
|
107013
|
107014
|
107015
|
107016
|
107017
|
107018
| 107019 |
107020
|
107021
|
107022
|
107023
|
107025