Bugzilla – Attachment 150827 Details for
Bug 32894
Objects cache methods' result without invalidation
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Help
|
New Account
|
Log In
[x]
|
Forgot Password
Login:
[x]
[patch]
Bug 32894: (follow-up) Koha::Item->last_returned_by
Bug-32894-follow-up-KohaItem-lastreturnedby.patch (text/plain), 2.03 KB, created by
Jonathan Druart
on 2023-05-09 09:04:13 UTC
(
hide
)
Description:
Bug 32894: (follow-up) Koha::Item->last_returned_by
Filename:
MIME Type:
Creator:
Jonathan Druart
Created:
2023-05-09 09:04:13 UTC
Size:
2.03 KB
patch
obsolete
>From 853ff523ea9a67d03f06665ec0658a97e7a7a9d5 Mon Sep 17 00:00:00 2001 >From: Jonathan Druart <jonathan.druart@bugs.koha-community.org> >Date: Tue, 9 May 2023 11:00:48 +0200 >Subject: [PATCH] Bug 32894: (follow-up) Koha::Item->last_returned_by > >--- > Koha/Item.pm | 16 ++++++++++++---- > t/db_dependent/Circulation/StoreLastBorrower.t | 2 +- > 2 files changed, 13 insertions(+), 5 deletions(-) > >diff --git a/Koha/Item.pm b/Koha/Item.pm >index 8b3539e4268..ea5e40f605d 100644 >--- a/Koha/Item.pm >+++ b/Koha/Item.pm >@@ -598,17 +598,25 @@ sub get_transfers { > > =head3 last_returned_by > >-Gets the last borrower to return an item. >+Gets and sets the last patron to return an item. > >-$last_returned_by = $item->last_returned_by(); >+Accepts a patron's id (borrowernumber) and returns Koha::Patron objects >+ >+$item->last_returned_by( $borrowernumber ); >+ >+my $patron = $item->last_returned_by(); > > =cut > > sub last_returned_by { >- my ( $self ) = @_; >+ my ( $self, $borrowernumber ) = @_; >+ if ( $borrowernumber ) { >+ $self->_result->update_or_create_related('last_returned_by', >+ { borrowernumber => $borrowernumber, itemnumber => $self->itemnumber } ); >+ } > my $rs = $self->_result->last_returned_by; > return unless $rs; >- return Koha::Patron->_new_from_dbic($rs); >+ return Koha::Patron->_new_from_dbic($rs->borrowernumber); > } > > =head3 can_article_request >diff --git a/t/db_dependent/Circulation/StoreLastBorrower.t b/t/db_dependent/Circulation/StoreLastBorrower.t >index b5c12b7e6bf..c3121bb954d 100755 >--- a/t/db_dependent/Circulation/StoreLastBorrower.t >+++ b/t/db_dependent/Circulation/StoreLastBorrower.t >@@ -98,7 +98,7 @@ subtest 'Test StoreLastBorrower' => sub { > ); > $patron_object = Koha::Patrons->find( $patron->{borrowernumber} ); > >- $item->last_returned_by($patron_object); >+ $item->last_returned_by($patron_object->borrowernumber); > $item = $item->get_from_storage; > my $patron_object2 = $item->last_returned_by(); > is( $patron_object->id, $patron_object2->id, >-- >2.25.1
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 32894
:
147499
|
147500
|
147502
|
147503
|
150016
|
150017
|
150018
|
150019
|
150020
|
150021
|
150827
|
150828
|
150847
|
150848
|
150849
|
150850
|
150851
|
150852
|
150853
|
150854
|
150855
|
152086
|
152087
|
152088
|
152089
|
152090
|
152091
|
152092
|
152093
|
152094