From 3a4fb7c1e3642286af6ec384d508855d1223f07a Mon Sep 17 00:00:00 2001 From: Matt Blenkinsop Date: Mon, 28 Apr 2025 09:44:48 +0100 Subject: [PATCH] Bug 39752: Check for biblio existence when matches are found Currently when adding to a basket from a new/staged file, we don't check whether a matched record still exists when importing. This patch changes the conditional check to be based on the existence of the biblio record rather than just on the biblionumber from the match Test plan: 1) Stage and import a record into Koha 2) Stage the same record again, this time matching on ISBN 3) Check that the match has been found in the batch details 4) Delete the original record that you imported in step 1 5) Find a basket, and add to it from a staged file 6) Choose the file/record you imported in stage 2 7) Select the record and save to add the orders 8) You will get a 500 error 9) Apply patch and restart_all 10) Refresh the page to re-submit the form 11) The form should submit correctly --- Koha/MarcOrder.pm | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/Koha/MarcOrder.pm b/Koha/MarcOrder.pm index 6cb39fa4377..e58cc5634a2 100644 --- a/Koha/MarcOrder.pm +++ b/Koha/MarcOrder.pm @@ -395,13 +395,13 @@ sub add_biblio_from_import_record { my $marcrecord = $import_record->get_marc_record || die "Couldn't translate MARC information"; my $matches = $import_record->get_import_record_matches( { chosen => 1 } ); - my $match = $matches->count ? $matches->next : undef; - my $biblionumber = $match ? $match->candidate_match_id : 0; + my $match = $matches->count ? $matches->next : undef; + my $biblionumber = $match ? $match->candidate_match_id : 0; + my $biblio = $biblionumber ? Koha::Biblios->find($biblionumber) : undef; - if ($biblionumber) { + if ($biblio) { $import_record->status('imported')->store; if ( $overlay_action eq 'replace' ) { - my $biblio = Koha::Biblios->find($biblionumber); $import_record->replace( { biblio => $biblio } ); } } else { -- 2.48.1