Bugzilla – Attachment 188704 Details for
Bug 37564
bulkmarcimport should not generate real time holds queue updates
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Help
|
New Account
|
Log In
[x]
|
Forgot Password
Login:
[x]
[patch]
Bug 37564: Prevent bulkmarcimport from generating holds queue jobs
Bug-37564-Prevent-bulkmarcimport-from-generating-h.patch (text/plain), 6.79 KB, created by
Nick Clemens (kidclamp)
on 2025-10-30 18:14:50 UTC
(
hide
)
Description:
Bug 37564: Prevent bulkmarcimport from generating holds queue jobs
Filename:
MIME Type:
Creator:
Nick Clemens (kidclamp)
Created:
2025-10-30 18:14:50 UTC
Size:
6.79 KB
patch
obsolete
>From 550361813428c5805838e06153cd26dccc2ba2a3 Mon Sep 17 00:00:00 2001 >From: Martin Renvoize <martin.renvoize@ptfs-europe.com> >Date: Tue, 7 Jan 2025 12:28:27 +0000 >Subject: [PATCH] Bug 37564: Prevent bulkmarcimport from generating holds queue > jobs > >We shouldn't need to update the holds queue for such command line >imports when only adding/updating a biblio. > >When we add a biblio and add items, we do not need to rebuild the holds queue as there >can't be holds on a new record > >If the record was matched and then updated or ignored we will need to rebuild the queue as we add items. > >TO DO: > - Right now we rebuild per item added, really we should probably skip the entire build until the end and handle here. > - We should also delay record index builds until all items have been added - currently we will reindex once per item > >Testing notes (using KTD): >1. Enable the real times hold queue: RealTimeHoldsQueue = Enable >2. Delete any background jobs: > DELETE FROM background_jobs; >3. Check the number of holds queue jobs in the database: > SELECT COUNT(*) FROM background_jobs WHERE type = update_holds_queue_for_biblios'; >4. Export a record with items as XML from Koha. >5. Delete the exported record from Koha >6. Import the record, using bulkmarcimport.pl: > misc/migration_tools/bulkmarcimport.pl -b -v -m=MARCXML --file my_record.marcxml >7. Check the jobs in the database, there should be one per item imported. >8. Delete the imported record >9. Delete all background jobs (see step 2). >10. Apply the patch >11. Import the record again (see step 6) >12. Check the number of holds queue jobs in the database again - should be 0. >13. Import biblio and use matchin option to overlay previous import >14. Check the number of holds queue jobs in the database again - should be one per item. >--- > C4/Items.pm | 11 ++++++----- > misc/migration_tools/bulkmarcimport.pl | 19 ++++++++++++++----- > 2 files changed, 20 insertions(+), 10 deletions(-) > >diff --git a/C4/Items.pm b/C4/Items.pm >index 9d426169a26..fddc2332360 100644 >--- a/C4/Items.pm >+++ b/C4/Items.pm >@@ -226,10 +226,11 @@ Additional information appropriate to the error condition. > =cut > > sub AddItemBatchFromMarc { >- my ( $record, $biblionumber, $biblioitemnumber, $frameworkcode ) = @_; >- my @itemnumbers = (); >- my @errors = (); >- my $dbh = C4::Context->dbh; >+ my ( $record, $biblionumber, $biblioitemnumber, $frameworkcode, $options ) = @_; >+ my @itemnumbers = (); >+ my @errors = (); >+ my $dbh = C4::Context->dbh; >+ my $skip_holds_queue = $options->{skip_holds_queue} // 0; > > # We modify the record, so lets work on a clone so we don't change the > # original. >@@ -266,7 +267,7 @@ ITEMFIELD: foreach my $item_field ( $record->field($itemtag) ) { > next ITEMFIELD; > } > >- my $item_object = Koha::Item->new($item)->store; >+ my $item_object = Koha::Item->new($item)->store( { skip_holds_queue => $skip_holds_queue } ); > push @itemnumbers, $item_object->itemnumber; # FIXME not checking error > > logaction( "CATALOGUING", "ADD", $item_object->itemnumber, "item" ) >diff --git a/misc/migration_tools/bulkmarcimport.pl b/misc/migration_tools/bulkmarcimport.pl >index cd5fa255a6e..856690c7be3 100755 >--- a/misc/migration_tools/bulkmarcimport.pl >+++ b/misc/migration_tools/bulkmarcimport.pl >@@ -134,12 +134,15 @@ my $using_elastic_search = ( C4::Context->preference('SearchEngine') eq 'Elastic > my $mod_biblio_options = { > disable_autolink => $using_elastic_search, > skip_record_index => $using_elastic_search || $skip_indexing, >+ skip_holds_queue => 1, > overlay_context => { source => 'bulkmarcimport' } > }; > my $add_biblio_options = { > disable_autolink => $using_elastic_search, >- skip_record_index => $using_elastic_search || $skip_indexing >+ skip_record_index => $using_elastic_search || $skip_indexing, >+ skip_holds_queue => 1, > }; >+ > my $mod_authority_options = { skip_record_index => $using_elastic_search || $skip_indexing }; > my $add_authority_options = { skip_record_index => $using_elastic_search || $skip_indexing }; > >@@ -329,7 +332,6 @@ $schema->txn_begin; > RECORD: while () { > > my $record; >- $record_number++; > > # get record > eval { $record = $batch->next() }; >@@ -542,6 +544,7 @@ RECORD: while () { > } > } else { > my ( $biblioitemnumber, $itemnumbers_ref, $errors_ref, $record_id ); >+ my $add_item_options = {}; # Will need to set this for each record > > # check for duplicate, based on ISBN (skip it if we already have found a duplicate with match parameter > if ( !$matched_record_id && $isbn_check && $isbn ) { >@@ -563,6 +566,9 @@ RECORD: while () { > > # Create biblio, unless we already have it (either match or ISBN) > if ($matched_record_id) { >+ $add_item_options->{skip_holds_queue} = >+ 0; #Existing record found, either updating or ignoring, need to update the queue >+ > eval { $biblioitemnumber = Koha::Biblios->find($matched_record_id)->biblioitem->biblioitemnumber; }; > if ($update) { > my $success; >@@ -594,6 +600,7 @@ RECORD: while () { > ) if ($logfile); > } > } elsif ($insert) { >+ $add_item_options->{skip_holds_queue} = 1; # New record, no need to update the queue > my $record_clone = $record->clone(); > C4::Biblio::_strip_item_fields($record_clone); > eval { >@@ -626,8 +633,10 @@ RECORD: while () { > if ($record_id) { > $yamlhash->{$originalid} = $record_id if $yamlfile; > eval { >- ( $itemnumbers_ref, $errors_ref ) = >- AddItemBatchFromMarc( $record, $record_id, $biblioitemnumber, $framework ); >+ ( $itemnumbers_ref, $errors_ref ) = AddItemBatchFromMarc( >+ $record, $record_id, $biblioitemnumber, $framework, >+ $add_item_options >+ ); > }; > my $error_adding = $@; > >@@ -680,7 +689,7 @@ RECORD: while () { > my $more_errors; > eval { > ( $itemnumbers_ref, $more_errors ) = >- AddItemBatchFromMarc( $record, $record_id, $biblioitemnumber, '' ); >+ AddItemBatchFromMarc( $record, $record_id, $biblioitemnumber, '', $add_item_options ); > }; > if ($@) { > warn "ERROR: Adding items to bib $record_id failed: $@\n"; >-- >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 37564
:
176186
|
176188
|
177199
|
177210
| 188704