Bugzilla – Attachment 182925 Details for
Bug 40058
Move RevertWaitingStatus to Koha::Hold->revert_waiting()
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Help
|
New Account
|
Log In
[x]
|
Forgot Password
Login:
[x]
[patch]
Bug 40058: Remove RevertWaitingStatus()
Bug-40058-Remove-RevertWaitingStatus.patch (text/plain), 5.98 KB, created by
Tomás Cohen Arazi (tcohen)
on 2025-06-03 15:12:17 UTC
(
hide
)
Description:
Bug 40058: Remove RevertWaitingStatus()
Filename:
MIME Type:
Creator:
Tomás Cohen Arazi (tcohen)
Created:
2025-06-03 15:12:17 UTC
Size:
5.98 KB
patch
obsolete
>From a5f0efe265366db2485510acead646f7dfa3927b Mon Sep 17 00:00:00 2001 >From: Tomas Cohen Arazi <tomascohen@theke.io> >Date: Tue, 3 Jun 2025 10:31:42 -0300 >Subject: [PATCH] Bug 40058: Remove RevertWaitingStatus() > >--- > C4/Circulation.pm | 7 +++-- > C4/Reserves.pm | 67 +++------------------------------------------- > reserve/request.pl | 5 ++-- > 3 files changed, 11 insertions(+), 68 deletions(-) > >diff --git a/C4/Circulation.pm b/C4/Circulation.pm >index bf93c32a590..c5d68ea94fb 100644 >--- a/C4/Circulation.pm >+++ b/C4/Circulation.pm >@@ -26,7 +26,7 @@ use Encode; > use C4::Context; > use C4::Stats qw( UpdateStats ); > use C4::Reserves >- qw( CheckReserves CanItemBeReserved MoveReserve ModReserve ModReserveMinusPriority RevertWaitingStatus IsAvailableForItemLevelRequest ); >+ qw( CheckReserves CanItemBeReserved MoveReserve ModReserve ModReserveMinusPriority IsAvailableForItemLevelRequest ); > use C4::Biblio qw( UpdateTotalIssues ); > use C4::Items qw( ModItemTransfer ModDateLastSeen CartToShelf ); > use C4::Accounts; >@@ -2529,9 +2529,12 @@ sub AddReturn { > my $lookahead = C4::Context->preference('ConfirmFutureHolds'); #number of days to look for future holds > ( $resfound, $resrec, undef ) = C4::Reserves::CheckReserves( $item, $lookahead ) unless ( $item->withdrawn ); > >+ # FIXME: CheckReserves should return the Koha::Hold >+ my $hold = Koha::Holds->find( $resrec->{reserve_id} ); >+ > # if a hold is found and is waiting at another branch, change the priority back to 1 and trigger the hold (this will trigger a transfer and update the hold status properly) > if ( $resfound and $resfound eq "Waiting" and $branch ne $resrec->{branchcode} ) { >- my $hold = C4::Reserves::RevertWaitingStatus( { itemnumber => $item->itemnumber } ); >+ $hold->revert_waiting(); > $resfound = 'Reserved'; > $resrec = $hold->unblessed; > } >diff --git a/C4/Reserves.pm b/C4/Reserves.pm >index 852768c3303..357229fde6d 100644 >--- a/C4/Reserves.pm >+++ b/C4/Reserves.pm >@@ -137,8 +137,6 @@ BEGIN { > GetMaxPatronHoldsForRecord > > MergeHolds >- >- RevertWaitingStatus > ); > } > >@@ -2084,10 +2082,10 @@ sub MoveReserve { > $hold->fill( { item_id => $item->id } ); > } > >- if ( $cancelreserve eq 'revert' ) { ## Revert waiting reserve to priority 1 >- RevertWaitingStatus( { itemnumber => $item->id } ); >+ $hold = Koha::Holds->find( $res->{reserve_id} ); >+ if ( $cancelreserve eq 'revert' ) { >+ $hold->revert_waiting(); > } elsif ( $cancelreserve eq 'cancel' || $cancelreserve ) { # cancel reserves on this item >- my $hold = Koha::Holds->find( $res->{reserve_id} ); > $hold->cancel; > } > } >@@ -2134,65 +2132,6 @@ sub MergeHolds { > } > } > >-=head2 RevertWaitingStatus >- >- RevertWaitingStatus({ itemnumber => $itemnumber }); >- >- Reverts a 'waiting' hold back to a regular hold with a priority of 1. >- >- Caveat: Any waiting hold fixed with RevertWaitingStatus will be an >- item level hold, even if it was only a bibliolevel hold to >- begin with. This is because we can no longer know if a hold >- was item-level or bib-level after a hold has been set to >- waiting status. >- >-=cut >- >-sub RevertWaitingStatus { >- my ($params) = @_; >- my $itemnumber = $params->{'itemnumber'}; >- >- return unless ($itemnumber); >- >- my $dbh = C4::Context->dbh; >- >- ## Get the waiting reserve we want to revert >- my $hold = Koha::Holds->search( >- { >- itemnumber => $itemnumber, >- found => { not => undef }, >- } >- )->next; >- >- my $original = C4::Context->preference('HoldsLog') ? $hold->unblessed : undef; >- >- ## Increment the priority of all other non-waiting >- ## reserves for this bib record >- my $holds = Koha::Holds->search( { biblionumber => $hold->biblionumber, priority => { '>' => 0 } } ) >- ->update( { priority => \'priority + 1' }, { no_triggers => 1 } ); >- >- ## Fix up the currently waiting reserve >- $hold->set( >- { >- priority => 1, >- found => undef, >- waitingdate => undef, >- expirationdate => $hold->patron_expiration_date, >- itemnumber => $hold->item_level_hold ? $hold->itemnumber : undef, >- } >- )->store( { hold_reverted => 1 } ); >- >- logaction( 'HOLDS', 'MODIFY', $hold->id, $hold, undef, $original ) >- if C4::Context->preference('HoldsLog'); >- >- _FixPriority( { biblionumber => $hold->biblionumber } ); >- >- Koha::BackgroundJob::BatchUpdateBiblioHoldsQueue->new->enqueue( { biblio_ids => [ $hold->biblionumber ] } ) >- if C4::Context->preference('RealTimeHoldsQueue'); >- >- return $hold; >-} >- > =head2 ReserveSlip > > ReserveSlip( >diff --git a/reserve/request.pl b/reserve/request.pl >index 5908ab692b7..d13d4446661 100755 >--- a/reserve/request.pl >+++ b/reserve/request.pl >@@ -33,7 +33,7 @@ use Date::Calc qw( Date_to_Days ); > use C4::Output qw( output_html_with_http_headers ); > use C4::Auth qw( get_template_and_user ); > use C4::Reserves >- qw( RevertWaitingStatus AlterPriority ToggleLowestPriority CanBookBeReserved GetMaxPatronHoldsForRecord CanItemBeReserved IsAvailableForItemLevelRequest ); >+ qw( AlterPriority ToggleLowestPriority CanBookBeReserved GetMaxPatronHoldsForRecord CanItemBeReserved IsAvailableForItemLevelRequest ); > use C4::Items qw( get_hostitemnumbers_of ); > use C4::Koha qw( getitemtypeimagelocation ); > use C4::Serials qw( CountSubscriptionFromBiblionumber ); >@@ -102,7 +102,8 @@ if ( $op eq 'cud-move' ) { > my $last_priority = $input->param('last_priority'); > my $hold_itemnumber = $input->param('itemnumber'); > if ( $prev_priority == 0 && $next_priority == 1 ) { >- C4::Reserves::RevertWaitingStatus( { itemnumber => $hold_itemnumber } ); >+ my $hold = Koha::Holds->find($reserve_id); >+ $hold->revert_waiting(); > } else { > AlterPriority( > $where, $reserve_id, $prev_priority, >-- >2.49.0
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 40058
:
182924
|
182925
|
182926
|
182941
|
182942
|
182943