Bugzilla – Attachment 147500 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: Koha::Item->last_returned_by
Bug-32894-KohaItem-lastreturnedby.patch (text/plain), 2.73 KB, created by
Jonathan Druart
on 2023-02-28 16:18:40 UTC
(
hide
)
Description:
Bug 32894: Koha::Item->last_returned_by
Filename:
MIME Type:
Creator:
Jonathan Druart
Created:
2023-02-28 16:18:40 UTC
Size:
2.73 KB
patch
obsolete
>From 0b36e72f176ec489b38ba08667305b13b1d5744b Mon Sep 17 00:00:00 2001 >From: Jonathan Druart <jonathan.druart@bugs.koha-community.org> >Date: Tue, 28 Feb 2023 16:13:56 +0100 >Subject: [PATCH] Bug 32894: Koha::Item->last_returned_by > >--- > C4/Circulation.pm | 2 +- > Koha/Item.pm | 28 +++++----------------------- > Koha/Schema/Result/Item.pm | 7 +++++++ > 3 files changed, 13 insertions(+), 24 deletions(-) > >diff --git a/C4/Circulation.pm b/C4/Circulation.pm >index c5c97012018..0739a80d552 100644 >--- a/C4/Circulation.pm >+++ b/C4/Circulation.pm >@@ -2555,7 +2555,7 @@ sub MarkIssueReturned { > > if ( C4::Context->preference('StoreLastBorrower') ) { > my $item = Koha::Items->find( $itemnumber ); >- $item->last_returned_by( $patron ); >+ $item->last_returned_by( $patron->borrowernumber )->store; > } > > # Remove any OVERDUES related debarment if the borrower has no overdues >diff --git a/Koha/Item.pm b/Koha/Item.pm >index 89d1a948c45..605ef53ae12 100644 >--- a/Koha/Item.pm >+++ b/Koha/Item.pm >@@ -599,35 +599,17 @@ sub get_transfers { > > =head3 last_returned_by > >-Gets and sets the last borrower to return an item. >- >-Accepts and returns Koha::Patron objects >- >-$item->last_returned_by( $borrowernumber ); >+Gets the last borrower to return an item. > > $last_returned_by = $item->last_returned_by(); > > =cut > > sub last_returned_by { >- my ( $self, $borrower ) = @_; >- >- my $items_last_returned_by_rs = Koha::Database->new()->schema()->resultset('ItemsLastBorrower'); >- >- if ($borrower) { >- return $items_last_returned_by_rs->update_or_create( >- { borrowernumber => $borrower->borrowernumber, itemnumber => $self->id } ); >- } >- else { >- unless ( $self->{_last_returned_by} ) { >- my $result = $items_last_returned_by_rs->single( { itemnumber => $self->id } ); >- if ($result) { >- $self->{_last_returned_by} = Koha::Patrons->find( $result->get_column('borrowernumber') ); >- } >- } >- >- return $self->{_last_returned_by}; >- } >+ my ( $self ) = @_; >+ my $rs = $self->_result->last_returned_by; >+ return unless $rs; >+ return Koha::Patron->_new_from_dbic($rs); > } > > =head3 can_article_request >diff --git a/Koha/Schema/Result/Item.pm b/Koha/Schema/Result/Item.pm >index 55d33e4a198..fbadf85456d 100644 >--- a/Koha/Schema/Result/Item.pm >+++ b/Koha/Schema/Result/Item.pm >@@ -968,6 +968,13 @@ __PACKAGE__->many_to_many( > "ordernumber", > ); > >+__PACKAGE__->might_have( >+ "last_returned_by", >+ "Koha::Schema::Result::ItemsLastBorrower", >+ { "foreign.itemnumber" => "self.itemnumber" }, >+ { cascade_copy => 0, cascade_delete => 0 }, >+); >+ > use C4::Context; > sub effective_itemtype { > my ( $self ) = @_; >-- >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