From d31f8d7279b6d11b6037884afd71ed411babac5e 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 Signed-off-by: David Nind Signed-off-by: Nick Clemens Signed-off-by: Katrin Fischer (cherry picked from commit 37538b22a07d503401a13a10caf18debcea05241) Signed-off-by: Fridolin Somers --- Koha/MarcOrder.pm | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/Koha/MarcOrder.pm b/Koha/MarcOrder.pm index df8d127685..9a86a27ba8 100644 --- a/Koha/MarcOrder.pm +++ b/Koha/MarcOrder.pm @@ -393,11 +393,11 @@ sub add_biblio_from_import_record { 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 $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 {