From 55737996ccaf02359ac9480bd43cbc9c38c354c3 Mon Sep 17 00:00:00 2001 From: Jonathan Druart Date: Wed, 30 May 2018 12:10:58 -0300 Subject: [PATCH] Bug 20829: Handle non-existent barcode when linking to host item Since commit 2c9aeb9b0f4449d1a25274b8fbf8dae4ec11d3bf Bug 18277: Remove GetBiblionumberFromItemnumber - linkitem $item is not defined if the barcode is invalid, we should not call method on it in that case. Test plan: - Turn on EasyAnalyticalRecords - Go to a detail page - Edit > Link to host item - Enter an invalid barcode => With the patch you get a friendly error message => Without this patch it explodes with Can't call method "itemnumber" on an undefined value at /home/vagrant/kohaclone/cataloguing/linkitem.pl line 86. --- cataloguing/linkitem.pl | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/cataloguing/linkitem.pl b/cataloguing/linkitem.pl index 40e2a98898..4ea4727559 100755 --- a/cataloguing/linkitem.pl +++ b/cataloguing/linkitem.pl @@ -75,6 +75,9 @@ if ( $barcode && $biblionumber ) { errornomodbiblio => 1 ); } + $template->param( + hostitemnumber => $item->itemnumber, + ); } else { $template->param( @@ -85,7 +88,6 @@ if ( $barcode && $biblionumber ) { $template->param( barcode => $barcode, - hostitemnumber => $item->itemnumber, ); } -- 2.11.0