Bugzilla – Attachment 171053 Details for
Bug 17729
Replace IsItemOnHoldAndFound with $item->holds->filter_by_found->count
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Help
|
New Account
|
Log In
[x]
|
Forgot Password
Login:
[x]
[patch]
Bug 17729: Replace IsItemOnHoldAndFound
Bug-17729-Replace-IsItemOnHoldAndFound.patch (text/plain), 3.70 KB, created by
Jonathan Druart
on 2024-09-05 10:53:35 UTC
(
hide
)
Description:
Bug 17729: Replace IsItemOnHoldAndFound
Filename:
MIME Type:
Creator:
Jonathan Druart
Created:
2024-09-05 10:53:35 UTC
Size:
3.70 KB
patch
obsolete
>From 5acafb35e19c1d88fca559c39790c8ea0eab2bf0 Mon Sep 17 00:00:00 2001 >From: Jonathan Druart <jonathan.druart@bugs.koha-community.org> >Date: Thu, 5 Sep 2024 12:47:53 +0200 >Subject: [PATCH] Bug 17729: Replace IsItemOnHoldAndFound > >This subroutine can easily be replaced with >$item->holds->filter_by_found->count \o/ > >Test plan: >Confirm that the old sub and $item->holds->filter_by_found->count >produce the same query >--- > C4/Circulation.pm | 4 ++-- > C4/Reserves.pm | 30 ++---------------------------- > 2 files changed, 4 insertions(+), 30 deletions(-) > >diff --git a/C4/Circulation.pm b/C4/Circulation.pm >index b454ff241f8..7c2a7257456 100644 >--- a/C4/Circulation.pm >+++ b/C4/Circulation.pm >@@ -25,7 +25,7 @@ use Encode; > > use C4::Context; > use C4::Stats qw( UpdateStats ); >-use C4::Reserves qw( CheckReserves CanItemBeReserved MoveReserve ModReserve ModReserveMinusPriority RevertWaitingStatus IsItemOnHoldAndFound IsAvailableForItemLevelRequest ); >+use C4::Reserves qw( CheckReserves CanItemBeReserved MoveReserve ModReserve ModReserveMinusPriority RevertWaitingStatus IsAvailableForItemLevelRequest ); > use C4::Biblio qw( UpdateTotalIssues ); > use C4::Items qw( ModItemTransfer ModDateLastSeen CartToShelf ); > use C4::Accounts; >@@ -3080,7 +3080,7 @@ sub CanBookBeRenewed { > > foreach my $other_item (@other_items) { > next if defined $matched_items{$other_item->itemnumber}; >- next if IsItemOnHoldAndFound( $other_item->itemnumber ); >+ next if $other_item->holds->filter_by_found->count; > next unless IsAvailableForItemLevelRequest($other_item, $patron_with_reserve, undef); > next unless CanItemBeReserved($patron_with_reserve,$other_item,undef,{ignore_hold_counts=>1})->{status} eq 'OK'; > # NOTE: At checkin we call 'CheckReserves' which checks hold 'policy' >diff --git a/C4/Reserves.pm b/C4/Reserves.pm >index c95a3d7ad42..fb18f85c76f 100644 >--- a/C4/Reserves.pm >+++ b/C4/Reserves.pm >@@ -137,8 +137,6 @@ BEGIN { > > CalculatePriority > >- IsItemOnHoldAndFound >- > GetMaxPatronHoldsForRecord > > MergeHolds >@@ -1421,7 +1419,7 @@ sub IsAvailableForItemLevelRequest { > return $any_available ? 0 : 1; > > } else { # on_shelf_holds == 0 "If any unavailable" (the description is rather cryptic and could still be improved) >- return $item->notforloan < 0 || $item->onloan || IsItemOnHoldAndFound( $item->itemnumber ); >+ return $item->notforloan < 0 || $item->onloan || $item->holds->filter_by_found->count; > } > } > >@@ -1453,7 +1451,7 @@ sub ItemsAnyAvailableAndNotRestricted { > || $i->notforloan # items with non-zero notforloan cannot be checked out > || $i->withdrawn > || $i->onloan >- || IsItemOnHoldAndFound( $i->id ) >+ || $i->holds->filter_by_found->count > || ( $i->damaged > && ! C4::Context->preference('AllowHoldsOnDamagedItems') ) > || Koha::ItemTypes->find( $i->effective_itemtype() )->notforloan >@@ -2283,30 +2281,6 @@ sub CalculatePriority { > return @row ? $row[0]+1 : 1; > } > >-=head2 IsItemOnHoldAndFound >- >- my $bool = IsItemFoundHold( $itemnumber ); >- >- Returns true if the item is currently on hold >- and that hold has a non-null found status ( W, T, etc. ) >- >-=cut >- >-sub IsItemOnHoldAndFound { >- my ($itemnumber) = @_; >- >- my $rs = Koha::Database->new()->schema()->resultset('Reserve'); >- >- my $found = $rs->count( >- { >- itemnumber => $itemnumber, >- found => { '!=' => undef } >- } >- ); >- >- return $found; >-} >- > =head2 GetMaxPatronHoldsForRecord > > my $holds_per_record = ReservesControlBranch( $borrowernumber, $biblionumber ); >-- >2.34.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 17729
:
57998
|
171053
|
171061
|
171065
|
171069