From 13badabaf8975259892b3781bf13bbc2c349a197 Mon Sep 17 00:00:00 2001 From: Marcel de Rooy Date: Mon, 4 Aug 2025 09:48:26 +0200 Subject: [PATCH] Bug 40585: Check on Biblios->find in addbybiblionumber scripts Just jumping to the next biblionumber (and adding found biblio recs) is more user friendly than crashing without any further clarification to the user. Note that this should be a rare exception when the URL is not manipulated (someone deleting a biblio while another wants to add it to a list). For another bug: The template is not designed to handle the situation that no biblio is found at all. Test plan: Select a biblio to add to a list and add a not-existent biblionumber to the URL. Without this patch, that URL will crash. With this patch, it will silently ignore a wrong biblionumber. Signed-off-by: Marcel de Rooy Signed-off-by: Owen Leonard Signed-off-by: Paul Derscheid Signed-off-by: Lucas Gass (cherry picked from commit 60b1cf95c447fb6c8fa80a7c1a1704fffd5ab15f) Signed-off-by: Paul Derscheid (cherry picked from commit 8198f36473cc50c6e2c8c97bd0d495cb01e9f7a6) Signed-off-by: Fridolin Somers --- opac/opac-addbybiblionumber.pl | 2 +- virtualshelves/addbybiblionumber.pl | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/opac/opac-addbybiblionumber.pl b/opac/opac-addbybiblionumber.pl index 3ea34220fd..3dddcedcc2 100755 --- a/opac/opac-addbybiblionumber.pl +++ b/opac/opac-addbybiblionumber.pl @@ -189,7 +189,7 @@ if( $op && $op !~ /^cud-/ ) { if ($authorized) { for my $biblionumber (@biblionumbers) { - my $biblio = Koha::Biblios->find( $biblionumber ); + my $biblio = Koha::Biblios->find($biblionumber) or next; push( @biblios, { biblionumber => $biblionumber, diff --git a/virtualshelves/addbybiblionumber.pl b/virtualshelves/addbybiblionumber.pl index 69483d5dc1..a5e68d8295 100755 --- a/virtualshelves/addbybiblionumber.pl +++ b/virtualshelves/addbybiblionumber.pl @@ -188,7 +188,7 @@ if ( $op && $op !~ /^cud-/ ) { my @biblios; for my $biblionumber (@biblionumbers) { - my $biblio = Koha::Biblios->find( $biblionumber ); + my $biblio = Koha::Biblios->find($biblionumber) or next; push( @biblios, { biblionumber => $biblionumber,