From 9924403902c2eccf8c79a85f1754080704257db3 Mon Sep 17 00:00:00 2001 From: Marcel de Rooy Date: Thu, 11 Dec 2025 14:08:00 +0100 Subject: [PATCH] Bug 40435: Module changes Content-Type: text/plain; charset=utf-8 CanBookBeRenewed will by default pass the skip_future_holds flag to item->current_holds so that renewals are not blocked by future holds. The new pref FutureHoldsBlockRenewals allows you to change that historical behavior. Test plan: [1] Set pref ConfirmFutureHolds=3, FutureHoldsBlockRenewals=Allow, OPACAllowHoldDateInFuture=Allow [2] Checkout some item to patron A. [3] Place hold on same item for patron B, reserve date tomorrow. [4] Try to renew item with patron A on account page. Should be marked as Not renewable. [5] Set pref FutureHoldsBlockRenewals=Dont [6] Repeat step 4. Renew should be allowed. [7] prove t/db_dependent/Holds.t t/db_dependent/Reserves.t Signed-off-by: Marcel de Rooy --- C4/Circulation.pm | 6 ++++-- Koha/Item.pm | 5 ++++- 2 files changed, 8 insertions(+), 3 deletions(-) diff --git a/C4/Circulation.pm b/C4/Circulation.pm index 0b2b57e375..163e1560d1 100644 --- a/C4/Circulation.pm +++ b/C4/Circulation.pm @@ -3269,9 +3269,11 @@ sub CanBookBeRenewed { } # There is an item level hold on this item, no other item can fill the hold - # The flag skip_future_holds may be removed in the future. See bug 40435. + # The flag skip_future_holds is set when preference FutureHoldsBlockRenewals is not set (default). + # (Historically, Koha does not block renewals for future holds. Could be argued.) + my $skip = C4::Context->preference('FutureHoldsBlockRenewals') ? 0 : 1; return ( 0, "on_reserve" ) - if ( $item->current_holds( { skip_future_holds => 1 } )->search( { non_priority => 0 } )->count ); + if ( $item->current_holds( { skip_future_holds => $skip } )->search( { non_priority => 0 } )->count ); my ( $status, $matched_reserve, $possible_holds ) = C4::Reserves::CheckReserves($item); my @fillable_holds = (); diff --git a/Koha/Item.pm b/Koha/Item.pm index d2b92c1956..865acdb578 100644 --- a/Koha/Item.pm +++ b/Koha/Item.pm @@ -1181,7 +1181,10 @@ sub article_request_type { my $holds = $item->current_holds Return the holds placed on this item. -Respects the lookahead days in ConfirmFutureHolds pref. +Respects the lookahead days in preference ConfirmFutureHolds when the +param skip_future_holds is not set. +Note that the preference FutureHoldsBlockRenewals controls that setting +for renewals; see also C4::Circulation::CanBookBeRenewed. =cut -- 2.39.5