Bug 36313: Fix Undefined subroutine &C4::Circulation::CheckReserves error

On (at least) git installations of Koha checkouts and checkins fail on
error 500. Logs have following error:

Undefined subroutine &C4::Circulation::CheckReserves called...

Error happens also when one tries to open patrons checkouts from detail page.
Koha doesn't die but table just keeps loading. Solution is to add C4::Reserves
before CheckReserves when it's called from Circulation.pm.

To test:
1. Apply this patch.
2. Try to check out and check in item.
=> Confirm both operations are succesfull.
3. Attempt to open patrons checkouts from patron detail and checkout page.
=> Table should load

Also prove t/db_dependent/Circulation.t.

Sponsored-by: Koha-Suomi Oy
Signed-off-by: BabaJaga <babajagawgoglach@gmail.com>
Signed-off-by: Martin Renvoize <martin.renvoize@ptfs-europe.com>
Signed-off-by: Katrin Fischer <katrin.fischer@bsz-bw.de>
(cherry picked from commit 80beaf875b)
Signed-off-by: Fridolin Somers <fridolin.somers@biblibre.com>
(cherry picked from commit d26306ed32)
Signed-off-by: Lucas Gass <lucas@bywatersolutions.com>
This commit is contained in:
Emmi Takkinen 2024-04-11 13:12:58 +03:00 committed by Lucas Gass
parent 2043237199
commit a82e0554fe

View file

@ -378,7 +378,7 @@ sub transferbook {
# find reserves..... # find reserves.....
# That'll save a database query. # That'll save a database query.
my ( $resfound, $resrec, undef ) = my ( $resfound, $resrec, undef ) =
CheckReserves( $item ); C4::Reserves::CheckReserves( $item );
if ( $resfound ) { if ( $resfound ) {
$resrec->{'ResFound'} = $resfound; $resrec->{'ResFound'} = $resfound;
$messages->{'ResFound'} = $resrec; $messages->{'ResFound'} = $resrec;
@ -1178,7 +1178,7 @@ sub CanBookBeIssued {
unless ( $ignore_reserves || $recall ) { unless ( $ignore_reserves || $recall ) {
# See if the item is on reserve. # See if the item is on reserve.
my ( $restype, $res ) = CheckReserves( $item_object ); my ( $restype, $res ) = C4::Reserves::CheckReserves( $item_object );
if ($restype) { if ($restype) {
my $resbor = $res->{'borrowernumber'}; my $resbor = $res->{'borrowernumber'};
if ( $resbor ne $patron->borrowernumber ) { if ( $resbor ne $patron->borrowernumber ) {
@ -1406,7 +1406,7 @@ sub checkHighHolds {
# Remove any items that are not holdable for this patron # Remove any items that are not holdable for this patron
# We need to ignore hold counts as the borrower's own hold that will be filled by the checkout # We need to ignore hold counts as the borrower's own hold that will be filled by the checkout
# could prevent them from placing further holds # could prevent them from placing further holds
@items = grep { CanItemBeReserved( $patron, $_, undef, { ignore_hold_counts => 1 } )->{status} eq 'OK' } @items; @items = grep { C4::Reserves::CanItemBeReserved( $patron, $_, undef, { ignore_hold_counts => 1 } )->{status} eq 'OK' } @items;
my $items_count = scalar @items; my $items_count = scalar @items;
@ -2434,7 +2434,7 @@ sub AddReturn {
# launch the Checkreserves routine to find any holds # launch the Checkreserves routine to find any holds
my ($resfound, $resrec); my ($resfound, $resrec);
my $lookahead= C4::Context->preference('ConfirmFutureHolds'); #number of days to look for future holds my $lookahead= C4::Context->preference('ConfirmFutureHolds'); #number of days to look for future holds
($resfound, $resrec, undef) = CheckReserves( $item, $lookahead ) unless ( $item->withdrawn ); ($resfound, $resrec, undef) = C4::Reserves::CheckReserves( $item, $lookahead ) unless ( $item->withdrawn );
# 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 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} ) { if ( $resfound and $resfound eq "Waiting" and $branch ne $resrec->{branchcode} ) {
my $hold = C4::Reserves::RevertWaitingStatus( { itemnumber => $item->itemnumber } ); my $hold = C4::Reserves::RevertWaitingStatus( { itemnumber => $item->itemnumber } );
@ -3040,7 +3040,7 @@ sub CanBookBeRenewed {
if ( $item->current_holds->search( { non_priority => 0 } )->count ); if ( $item->current_holds->search( { non_priority => 0 } )->count );
my ( $status, $matched_reserve, $possible_holds ) = CheckReserves($item); my ( $status, $matched_reserve, $possible_holds ) = C4::Reserves::CheckReserves($item);
my @fillable_holds = (); my @fillable_holds = ();
foreach my $possible_hold ( @{$possible_holds} ) { foreach my $possible_hold ( @{$possible_holds} ) {
push @fillable_holds, $possible_hold unless $possible_hold->{non_priority}; push @fillable_holds, $possible_hold unless $possible_hold->{non_priority};