Bugzilla – Attachment 51637 Details for
Bug 15333
Use Koha::Cache for caching all holidays
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Help
|
New Account
|
Log In
[x]
|
Forgot Password
Login:
[x]
[patch]
Bug 15333: Use Koha::Cache to cache exception_holidays instead of a package variable
Bug-15333-Use-KohaCache-to-cache-exceptionholidays.patch (text/plain), 4.28 KB, created by
Marcel de Rooy
on 2016-05-20 08:33:19 UTC
(
hide
)
Description:
Bug 15333: Use Koha::Cache to cache exception_holidays instead of a package variable
Filename:
MIME Type:
Creator:
Marcel de Rooy
Created:
2016-05-20 08:33:19 UTC
Size:
4.28 KB
patch
obsolete
>From 33acb92a3e749593d114c87162024e6e307b23eb Mon Sep 17 00:00:00 2001 >From: Jonathan Druart <jonathan.druart@bugs.koha-community.org> >Date: Wed, 4 May 2016 20:35:39 +0100 >Subject: [PATCH] Bug 15333: Use Koha::Cache to cache exception_holidays > instead of a package variable >Content-Type: text/plain; charset=utf-8 > >On the same way as bug 14522, we should use Koha::Cache to cache >exception_holidays. >It's not safe to use a package variable if running under Plack. > >There is not test plan, just make sure the changes make sense. > >Signed-off-by: Marcel de Rooy <m.de.rooy@rijksmuseum.nl> >--- > C4/Calendar.pm | 7 +++++++ > Koha/Calendar.pm | 21 ++++++--------------- > 2 files changed, 13 insertions(+), 15 deletions(-) > >diff --git a/C4/Calendar.pm b/C4/Calendar.pm >index 852bdd7..82dc35a 100644 >--- a/C4/Calendar.pm >+++ b/C4/Calendar.pm >@@ -278,6 +278,7 @@ sub insert_single_holiday { > # changed the 'single_holidays' table, lets force/reset its cache > my $cache = Koha::Cache->get_instance(); > $cache->clear_from_cache( 'single_holidays') ; >+ $cache->clear_from_cache( 'exception_holidays') ; > > return $self; > >@@ -322,6 +323,7 @@ sub insert_exception_holiday { > # changed the 'single_holidays' table, lets force/reset its cache > my $cache = Koha::Cache->get_instance(); > $cache->clear_from_cache( 'single_holidays') ; >+ $cache->clear_from_cache( 'exception_holidays') ; > > return $self; > } >@@ -422,6 +424,7 @@ UPDATE special_holidays SET title = ?, description = ? > # changed the 'single_holidays' table, lets force/reset its cache > my $cache = Koha::Cache->get_instance(); > $cache->clear_from_cache( 'single_holidays') ; >+ $cache->clear_from_cache( 'exception_holidays') ; > > return $self; > } >@@ -464,6 +467,7 @@ UPDATE special_holidays SET title = ?, description = ? > # changed the 'single_holidays' table, lets force/reset its cache > my $cache = Koha::Cache->get_instance(); > $cache->clear_from_cache( 'single_holidays') ; >+ $cache->clear_from_cache( 'exception_holidays') ; > > return $self; > } >@@ -544,6 +548,7 @@ sub delete_holiday { > # changed the 'single_holidays' table, lets force/reset its cache > my $cache = Koha::Cache->get_instance(); > $cache->clear_from_cache( 'single_holidays') ; >+ $cache->clear_from_cache( 'exception_holidays') ; > > return $self; > } >@@ -574,6 +579,7 @@ sub delete_holiday_range { > # changed the 'single_holidays' table, lets force/reset its cache > my $cache = Koha::Cache->get_instance(); > $cache->clear_from_cache( 'single_holidays') ; >+ $cache->clear_from_cache( 'exception_holidays') ; > > } > >@@ -627,6 +633,7 @@ sub delete_exception_holiday_range { > # changed the 'single_holidays' table, lets force/reset its cache > my $cache = Koha::Cache->get_instance(); > $cache->clear_from_cache( 'single_holidays') ; >+ $cache->clear_from_cache( 'exception_holidays') ; > } > > =head2 isHoliday >diff --git a/Koha/Calendar.pm b/Koha/Calendar.pm >index 7095aca..f027ba7 100644 >--- a/Koha/Calendar.pm >+++ b/Koha/Calendar.pm >@@ -52,23 +52,14 @@ sub _init { > return; > } > >- >-# FIXME: use of package-level variables for caching the holiday >-# lists breaks persistance engines. As of 2013-12-10, the RM >-# is allowing this with the expectation that prior to release of >-# 3.16, bug 8089 will be fixed and we can switch the caching over >-# to Koha::Cache. >- >-our $exception_holidays; >- > sub exception_holidays { > my ( $self ) = @_; > my $dbh = C4::Context->dbh; > my $branch = $self->{branchcode}; >- if ( $exception_holidays ) { >- $self->{exception_holidays} = $exception_holidays; >- return $exception_holidays; >- } >+ my $cache = Koha::Cache->get_instance(); >+ my $cached = $cache->get_from_cache('exception_holidays'); >+ return $cached if $cached; >+ > my $exception_holidays_sth = $dbh->prepare( > 'SELECT day, month, year FROM special_holidays WHERE branchcode = ? AND isexception = 1' > ); >@@ -85,8 +76,8 @@ sub exception_holidays { > } > $self->{exception_holidays} = > DateTime::Set->from_datetimes( dates => $dates ); >- $exception_holidays = $self->{exception_holidays}; >- return $exception_holidays; >+ $cache->set_in_cache( 'exception_holidays', $self->{exception_holidays} ); >+ return $self->{exception_holidays}; > } > > sub single_holidays { >-- >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 15333
:
51223
| 51637 |
51638