Bugzilla – Attachment 186593 Details for
Bug 34596
Items in transit should not show up in the holds queue
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Help
|
New Account
|
Log In
[x]
|
Forgot Password
Login:
[x]
[patch]
Bug 34596: Add rebuild queue where needed for existing calls to AddReturn
Bug-34596-Add-rebuild-queue-where-needed-for-exist.patch (text/plain), 9.66 KB, created by
Nick Clemens (kidclamp)
on 2025-09-18 20:23:32 UTC
(
hide
)
Description:
Bug 34596: Add rebuild queue where needed for existing calls to AddReturn
Filename:
MIME Type:
Creator:
Nick Clemens (kidclamp)
Created:
2025-09-18 20:23:32 UTC
Size:
9.66 KB
patch
obsolete
>From 0aa3bafe2c2c1e3c8f81cf0cc9b736bc3bd09bfa Mon Sep 17 00:00:00 2001 >From: Nick Clemens <nick@bywatersolutions.com> >Date: Thu, 18 Sep 2025 19:21:02 +0000 >Subject: [PATCH] Bug 34596: Add rebuild queue where needed for existing calls > to AddReturn > >--- > C4/Circulation.pm | 1 + > C4/SIP/ILS/Transaction/Checkin.pm | 5 +++++ > Koha/Checkouts.pm | 8 +++++++- > Koha/Item.pm | 9 ++++++++- > circ/circulation.pl | 3 +++ > circ/returns.pl | 10 ++++++++-- > opac/sci/sci-main.pl | 6 ++++++ > svc/checkin | 4 ++++ > svc/recall | 1 - > tools/inventory.pl | 6 ++++++ > 10 files changed, 48 insertions(+), 5 deletions(-) > >diff --git a/C4/Circulation.pm b/C4/Circulation.pm >index b6eef2534f1..ea841d7749c 100644 >--- a/C4/Circulation.pm >+++ b/C4/Circulation.pm >@@ -2047,6 +2047,7 @@ sub AddIssue { > } > ); > >+ # Rebuilding holds queue here to ensure the item is removed from current queue > Koha::BackgroundJob::BatchUpdateBiblioHoldsQueue->new->enqueue( > { biblio_ids => [ $item_object->biblionumber ] } ) > if C4::Context->preference('RealTimeHoldsQueue'); >diff --git a/C4/SIP/ILS/Transaction/Checkin.pm b/C4/SIP/ILS/Transaction/Checkin.pm >index 94087723a84..558216f8216 100644 >--- a/C4/SIP/ILS/Transaction/Checkin.pm >+++ b/C4/SIP/ILS/Transaction/Checkin.pm >@@ -14,6 +14,7 @@ use C4::SIP::ILS::Transaction; > use C4::Circulation qw( AddReturn LostItem ); > use C4::Items qw( ModItemTransfer ); > use C4::Reserves qw( ModReserve ModReserveAffect CheckReserves ); >+use Koha::BackgroundJob::BatchUpdateBiblioHoldsQueue; > use Koha::DateUtils qw( dt_from_string ); > use Koha::Items; > >@@ -206,6 +207,10 @@ sub do_checkin { > $self->alert( !$return || defined $self->alert_type ); > } > >+ # If item has been returned let's update the queue after transfers/holds handled above >+ Koha::BackgroundJob::BatchUpdateBiblioHoldsQueue->new->enqueue( { biblio_ids => [ $item->biblionumber ] } ) >+ if $return && C4::Context->preference('RealTimeHoldsQueue'); >+ > # Set sort bin based on info in the item associated with the issue, and the > # mapping from SIP2SortBinMapping > $self->sort_bin( _get_sort_bin( $item, $branch, $account ) ); >diff --git a/Koha/Checkouts.pm b/Koha/Checkouts.pm >index b4ee3f8cf6f..8eba0ebc78a 100644 >--- a/Koha/Checkouts.pm >+++ b/Koha/Checkouts.pm >@@ -21,6 +21,7 @@ use Modern::Perl; > > use C4::Context; > use C4::Circulation qw( AddReturn ); >+use Koha::BackgroundJob::BatchUpdateBiblioHoldsQueue; > use Koha::Checkout; > use Koha::Database; > use Koha::DateUtils qw( dt_from_string ); >@@ -84,7 +85,7 @@ sub automatic_checkin { > > while ( my $checkout = $due_checkouts->next ) { > if ( $checkout->item->itemtype->automatic_checkin ) { >- my ( undef, $messages ) = C4::Circulation::AddReturn( >+ my ( $returned, $messages ) = C4::Circulation::AddReturn( > $checkout->item->barcode, $checkout->branchcode, undef, > dt_from_string( $checkout->date_due ) > ); >@@ -103,6 +104,11 @@ sub automatic_checkin { > } > } > } >+ >+ # If item is checked in let's update the holds queue, after hold/transfers handled above >+ Koha::BackgroundJob::BatchUpdateBiblioHoldsQueue->new->enqueue( >+ { biblio_ids => [ $checkout->item->biblionumber ] } ) >+ if $returned && C4::Context->preference('RealTimeHoldsQueue'); > } > } > } >diff --git a/Koha/Item.pm b/Koha/Item.pm >index c675d0638e4..ec0d8d2e531 100644 >--- a/Koha/Item.pm >+++ b/Koha/Item.pm >@@ -2307,7 +2307,14 @@ sub add_to_bundle { > > my $branchcode = C4::Context->userenv->{'branch'}; > my ($success) = C4::Circulation::AddReturn( $bundle_item->barcode, $branchcode ); >- unless ($success) { >+ >+ if ($success) { >+ >+ # HoldsQueue doesn't seem to mind bundles, not sure if this is correct, but rebuild for now >+ Koha::BackgroundJob::BatchUpdateBiblioHoldsQueue->new->enqueue( >+ { biblio_ids => [ $self->biblionumber ] } ) >+ if C4::Context->preference('RealTimeHoldsQueue'); >+ } else { > Koha::Exceptions::Checkin::FailedCheckin->throw(); > } > } >diff --git a/circ/circulation.pl b/circ/circulation.pl >index ad12dafaa82..653ff4c2cc8 100755 >--- a/circ/circulation.pl >+++ b/circ/circulation.pl >@@ -44,6 +44,7 @@ use Koha::Holds; > use C4::Context; > use CGI::Session; > use Koha::AuthorisedValues; >+use Koha::BackgroundJob::BatchUpdateBiblioHoldsQueue; > use Koha::Checkouts::ReturnClaims; > use Koha::CsvProfiles; > use Koha::Patrons; >@@ -379,6 +380,8 @@ if ( @$barcodes && $op eq 'cud-checkout' ) { > my ( $stats_return, $stats_messages, $stats_iteminformation, $stats_borrower ) = > AddReturn( $item->barcode, C4::Context->userenv->{'branch'}, undef, undef, 1 ); > >+ # No rebuild of holds queue here as the item hasn't really moved, just a stat checkout >+ > $template->param( > STATS => 1, > CHECKEDIN => $stats_return, >diff --git a/circ/returns.pl b/circ/returns.pl >index 1009cee5774..8ffb033a9ce 100755 >--- a/circ/returns.pl >+++ b/circ/returns.pl >@@ -44,6 +44,7 @@ use C4::Reserves qw( ModReserve ModReserveAffect CheckReserves ); > use C4::RotatingCollections; > use C4::Log qw( logaction ); > use Koha::AuthorisedValues; >+use Koha::BackgroundJob::BatchUpdateBiblioHoldsQueue; > use Koha::BiblioFrameworks; > use Koha::Calendar; > use Koha::Checkouts; >@@ -387,8 +388,13 @@ if ( $barcode && ( $op eq 'cud-checkin' || $op eq 'cud-affect_reserve' ) ) { > } > > # do the return >- ( $returned, $messages, $issue, $borrower ) = AddReturn( $barcode, $userenv_branch, $exemptfine, $return_date ) >- unless ( $needs_confirm || $bundle_confirm ); >+ unless ( $needs_confirm || $bundle_confirm ) { >+ ( $returned, $messages, $issue, $borrower ) = AddReturn( $barcode, $userenv_branch, $exemptfine, $return_date ); >+ >+ # Rebuild the queue only after handling confirmations >+ Koha::BackgroundJob::BatchUpdateBiblioHoldsQueue->new->enqueue( { biblio_ids => [ $item->biblionumber ] } ) >+ if $returned && C4::Context->preference('RealTimeHoldsQueue'); >+ } > > if ($returned) { > my $date_due_dt = dt_from_string( $issue->date_due, 'sql' ); >diff --git a/opac/sci/sci-main.pl b/opac/sci/sci-main.pl >index 34d433a53fc..74ed45759c5 100755 >--- a/opac/sci/sci-main.pl >+++ b/opac/sci/sci-main.pl >@@ -22,6 +22,7 @@ use CGI qw ( -utf8 ); > use C4::Auth qw( get_template_and_user ); > use C4::Circulation qw( AddReturn ); > use C4::Output qw( output_html_with_http_headers ); >+use Koha::BackgroundJob::BatchUpdateBiblioHoldsQueue; > use Koha::Items; > > use List::MoreUtils qw( uniq ); >@@ -86,6 +87,11 @@ if ( $op eq 'cud-check_in' ) { > checkout => $checkout, > patron => $patron > }; >+ >+ # Rebuild holds queue on checkin >+ Koha::BackgroundJob::BatchUpdateBiblioHoldsQueue->new->enqueue( >+ { biblio_ids => [ $item->biblionumber ] } ) >+ if C4::Context->preference('RealTimeHoldsQueue'); > } else { > push @errors, > { >diff --git a/svc/checkin b/svc/checkin >index 9d9445f4f77..b0be08025b4 100755 >--- a/svc/checkin >+++ b/svc/checkin >@@ -26,6 +26,7 @@ use JSON qw(to_json); > use C4::Circulation qw( AddReturn ); > use C4::Context; > use C4::Auth qw(check_cookie_auth); >+use Koha::BackgroundJob::BatchUpdateBiblioHoldsQueue; > use Koha::Checkouts; > use Koha::Items; > >@@ -68,5 +69,8 @@ my $checkout = Koha::Checkouts->find( { itemnumber => $itemnumber } ); > $data->{patronnote} = $checkout ? $checkout->note : q||; > > ( $data->{returned} ) = AddReturn( $barcode, $branchcode, $exempt_fine ); >+# Rebuild holds queue if item returns >+Koha::BackgroundJob::BatchUpdateBiblioHoldsQueue->new->enqueue( { biblio_ids => [ $item->biblionumber ] } ) >+ if C4::Context->preference('RealTimeHoldsQueue'); > > print to_json($data); >diff --git a/svc/recall b/svc/recall >index 6d0400f6b14..cb5705c5953 100755 >--- a/svc/recall >+++ b/svc/recall >@@ -24,7 +24,6 @@ use JSON qw(encode_json); > use C4::Context; > use C4::Auth qw(check_cookie_auth); > use C4::Output qw(output_with_http_headers); >-use C4::Circulation qw(AddReturn); > use Koha::Recalls; > > my $input = CGI->new; >diff --git a/tools/inventory.pl b/tools/inventory.pl >index a3429357844..5aad6e01471 100755 >--- a/tools/inventory.pl >+++ b/tools/inventory.pl >@@ -36,6 +36,7 @@ use C4::Reports::Guided qw( ); > use C4::Charset qw( NormalizeString ); > > use Koha::I18N qw(__); >+use Koha::BackgroundJob::BatchUpdateBiblioHoldsQueue; > use Koha::Biblios; > use Koha::DateUtils qw( dt_from_string ); > use Koha::Database::Columns; >@@ -269,6 +270,11 @@ if ( $op eq 'cud-inventory' > if ($doreturn) { > $item_unblessed->{onloan} = undef; > $item_unblessed->{datelastseen} = dt_from_string; >+ >+ # Rebuild the holds queue when item found on shelf >+ Koha::BackgroundJob::BatchUpdateBiblioHoldsQueue->new->enqueue( >+ { biblio_ids => [ $item->biblionumber ] } ) >+ if C4::Context->preference('RealTimeHoldsQueue'); > } else { > push @errorloop, { barcode => $barcode, ERR_ONLOAN_NOT_RET => 1 }; > } >-- >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 34596
:
174811
|
175804
|
186592
|
186593
|
186594
|
186595
|
186596
|
186597