Bugzilla – Attachment 162539 Details for
Bug 32476
Add caching for relatively expensive patron methods
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Help
|
New Account
|
Log In
[x]
|
Forgot Password
Login:
[x]
[patch]
Bug 32476: Fix Circulation tests and exclude cache param from cache key
Bug-32476-Fix-Circulation-tests-and-exclude-cache-.patch (text/plain), 2.52 KB, created by
David Gustafsson
on 2024-02-28 16:09:42 UTC
(
hide
)
Description:
Bug 32476: Fix Circulation tests and exclude cache param from cache key
Filename:
MIME Type:
Creator:
David Gustafsson
Created:
2024-02-28 16:09:42 UTC
Size:
2.52 KB
patch
obsolete
>From b4632daa7cb6fdb25c82a6ab30220feffc562222 Mon Sep 17 00:00:00 2001 >From: David Gustafsson <david.gustafsson@ub.gu.se> >Date: Wed, 28 Feb 2024 16:59:29 +0100 >Subject: [PATCH] Bug 32476: Fix Circulation tests and exclude cache param from > cache key > >--- > Koha/Object.pm | 10 ++++++---- > t/db_dependent/Circulation.t | 6 ++++++ > 2 files changed, 12 insertions(+), 4 deletions(-) > >diff --git a/Koha/Object.pm b/Koha/Object.pm >index 4086caf3169..5c54ae020bc 100644 >--- a/Koha/Object.pm >+++ b/Koha/Object.pm >@@ -177,16 +177,18 @@ my $value = Koha::Object->_method_cache($method_name, @args); > sub _method_cache { > my ($self, $method_name, @args) = @_; > >+ # Don't include in cache key. Must also be unset in >+ # possible uncached call to $method_name below >+ if (@args) { >+ delete $args[0]->{cache}; >+ } >+ > my $cache_key = $self->_method_cache_key($method_name, @args); > my $value = $self->_instance_cache_get($cache_key); > > return $value if defined $value; > >- if (@args) { >- delete $args[0]->{cache}; >- } > $value = $self->$method_name(@args); >- > $self->_instance_cache_set($cache_key, $value); > > return $value; >diff --git a/t/db_dependent/Circulation.t b/t/db_dependent/Circulation.t >index 5095afde735..2429bd86c91 100755 >--- a/t/db_dependent/Circulation.t >+++ b/t/db_dependent/Circulation.t >@@ -734,6 +734,9 @@ subtest "CanBookBeRenewed tests" => sub { > is( $renewokay, 1, '(Bug 8236), Can renew, this item is overdue but not pref does not block'); > > t::lib::Mocks::mock_preference('OverduesBlockRenewing','block'); >+ # Clear cache after changing preference affecting has_overdues evaluation >+ $renewing_borrower_obj->_method_cache_clear('has_overdues'); >+ > ( $renewokay, $error ) = CanBookBeRenewed($renewing_borrower_obj, $issue_6); > is( $renewokay, 0, '(Bug 8236), Cannot renew, this item is not overdue but patron has overdues'); > is( $error, 'overdue', "Correct error returned"); >@@ -742,6 +745,9 @@ subtest "CanBookBeRenewed tests" => sub { > is( $error, 'overdue', "Correct error returned"); > > t::lib::Mocks::mock_preference('OverduesBlockRenewing','blockitem'); >+ # Clear cache after changing preference affecting has_overdues evaluation >+ $renewing_borrower_obj->_method_cache_clear('has_overdues'); >+ > ( $renewokay, $error ) = CanBookBeRenewed($renewing_borrower_obj, $issue_6); > is( $renewokay, 1, '(Bug 8236), Can renew, this item is not overdue'); > ( $renewokay, $error ) = CanBookBeRenewed($renewing_borrower_obj, $issue_7); >-- >2.43.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 32476
:
144626
|
144627
|
144744
|
144770
|
144771
|
145036
|
145037
|
147145
|
147148
|
150778
|
150779
|
157241
|
157258
|
157259
|
162537
|
162538
| 162539