Bugzilla – Attachment 184443 Details for
Bug 37651
biblio->current_holds and item->current_holds do not respect ConfirmFutureHolds
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Help
|
New Account
|
Log In
[x]
|
Forgot Password
Login:
[x]
[patch]
Bug 37651: (follow-up) Still skip future holds for renewals
Bug-37651-follow-up-Still-skip-future-holds-for-re.patch (text/plain), 4.07 KB, created by
Marcel de Rooy
on 2025-07-21 14:19:46 UTC
(
hide
)
Description:
Bug 37651: (follow-up) Still skip future holds for renewals
Filename:
MIME Type:
Creator:
Marcel de Rooy
Created:
2025-07-21 14:19:46 UTC
Size:
4.07 KB
patch
obsolete
>From 85d3a2403f401d80de8732e98699b53cd4d497c5 Mon Sep 17 00:00:00 2001 >From: Marcel de Rooy <m.de.rooy@rijksmuseum.nl> >Date: Thu, 17 Jul 2025 15:24:44 +0200 >Subject: [PATCH] Bug 37651: (follow-up) Still skip future holds for renewals >Content-Type: text/plain; charset=utf-8 > >We need a skip_future_holds flag in item->current_holds to make renewals >act as they did before. There is no need to add it to biblio->current_holds. > >Test plan: >Run t/db_dependent/Holds.t >Interface test: Issue a book, place hold on tomorrow, set ConfirmFutureHolds >to 2 days. Verify that renew is not blocked by this hold. > >Signed-off-by: Marcel de Rooy <m.de.rooy@rijksmuseum.nl> >--- > C4/Circulation.pm | 3 ++- > Koha/Item.pm | 10 ++++++---- > t/db_dependent/Holds.t | 15 ++++++++++++++- > 3 files changed, 22 insertions(+), 6 deletions(-) > >diff --git a/C4/Circulation.pm b/C4/Circulation.pm >index f9cf48a605..376f457bbe 100644 >--- a/C4/Circulation.pm >+++ b/C4/Circulation.pm >@@ -3191,8 +3191,9 @@ 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. > return ( 0, "on_reserve" ) >- if ( $item->current_holds->search( { non_priority => 0 } )->count ); >+ if ( $item->current_holds( { skip_future_holds => 1 } )->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 d17a0f103a..1a5e70e846 100644 >--- a/Koha/Item.pm >+++ b/Koha/Item.pm >@@ -1164,11 +1164,13 @@ Respects the lookahead days in ConfirmFutureHolds pref. > =cut > > sub current_holds { >- my ($self) = @_; >+ my ( $self, $params ) = @_; >+ > my $attributes = { order_by => 'priority' }; > my $dtf = Koha::Database->new->schema->storage->datetime_parser; >- my $dt = dt_from_string()->add( days => C4::Context->preference('ConfirmFutureHolds') || 0 ); >- my $params = { >+ my $days = $params->{skip_future_holds} ? 0 : C4::Context->preference('ConfirmFutureHolds') || 0; >+ my $dt = dt_from_string()->add( days => $days ); >+ my $s_params = { > itemnumber => $self->itemnumber, > suspend => 0, > -or => [ >@@ -1176,7 +1178,7 @@ sub current_holds { > waitingdate => { '!=' => undef }, > ], > }; >- my $hold_rs = $self->_result->reserves->search( $params, $attributes ); >+ my $hold_rs = $self->_result->reserves->search( $s_params, $attributes ); > return Koha::Holds->_new_from_dbic($hold_rs); > } > >diff --git a/t/db_dependent/Holds.t b/t/db_dependent/Holds.t >index 197ded172c..52a5158d2e 100755 >--- a/t/db_dependent/Holds.t >+++ b/t/db_dependent/Holds.t >@@ -2111,7 +2111,7 @@ subtest 'EmailPatronWhenHoldIsPlaced tests' => sub { > }; > > subtest 'current_holds with future holds' => sub { >- plan tests => 2; >+ plan tests => 5; > $schema->storage->txn_begin; > > t::lib::Mocks::mock_preference( 'ConfirmFutureHolds', 2 ); >@@ -2130,5 +2130,18 @@ subtest 'current_holds with future holds' => sub { > t::lib::Mocks::mock_preference( 'ConfirmFutureHolds', 0 ); > is( $item->biblio->current_holds->count, 0, 'No future hold was counted when ConfirmFutureHolds is zero' ); > >+ # Test if renewal ignores future holds (until we decide otherwise; see bug 40435) >+ my $patron2 = $builder->build_object( { class => 'Koha::Patrons' } ); >+ t::lib::Mocks::mock_userenv( { branchcode => $patron2->branchcode } ); >+ my $issue = C4::Circulation::AddIssue( $patron2, $item->barcode, dt_from_string() ); >+ my ( $ok, $err ) = CanBookBeRenewed( $patron2, $issue ); >+ is( $ok, 1, 'Hold does not block renewal' ); >+ >+ # Changing the reservedate should block the renewal >+ Koha::Holds->find($hold_id)->reservedate( dt_from_string() )->store; >+ ( $ok, $err ) = CanBookBeRenewed( $patron2, $issue ); >+ is( $ok, 0, 'Hold now blocks renewal' ); >+ is( $err, 'on_reserve', 'Code for blocking renewal' ); >+ > $schema->storage->txn_rollback; > }; >-- >2.39.5
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 37651
:
171247
|
171248
|
171249
|
171250
|
176654
|
176655
|
176656
|
176808
|
176809
|
176810
|
176811
|
177372
|
178325
|
178326
|
178327
|
178328
|
178329
|
184438
|
184439
|
184440
|
184441
|
184442
|
184443
|
184444
|
185365
|
185366
|
185367
|
185368
|
185369
|
185370
|
185371
|
185706