From c2a7d26d781c91e9a4f8c7c3dd35894bde2ef193 Mon Sep 17 00:00:00 2001 From: Kyle M Hall Date: Mon, 25 Nov 2019 13:18:16 -0500 Subject: [PATCH] Bug 24106: In returns.pl, don't search for item if no barcode is provided When loading returns.pl, code to check rotating collections fires off an search for items by barcode, but doesn't check for a barcode first. This means the code will search for items where barcode is NULL, which is definitely not the intended function. Test Plan: 1) Apply this patch 2) Set up a rotating collection with items 3) Transfer the collection 4) Check in a rotating collection item 5) Note no change in functionality --- circ/returns.pl | 28 +++++++++++++++------------- 1 file changed, 15 insertions(+), 13 deletions(-) diff --git a/circ/returns.pl b/circ/returns.pl index 5e7d8e24bc..a9e2bc243c 100755 --- a/circ/returns.pl +++ b/circ/returns.pl @@ -634,19 +634,21 @@ $template->param( AudioAlerts => C4::Context->preference("AudioAlerts"), ); -my $item_from_barcode = Koha::Items->find({barcode => $barcode }); # How many times do we fetch this item?!? -if ( $item_from_barcode ) { - $itemnumber = $item_from_barcode->itemnumber; - my ( $holdingBranch, $collectionBranch ) = GetCollectionItemBranches( $itemnumber ); - if ( $holdingBranch and $collectionBranch ) { - $holdingBranch //= ''; - $collectionBranch //= $returnbranch; - if ( ! ( $holdingBranch eq $collectionBranch ) ) { - $template->param( - collectionItemNeedsTransferred => 1, - collectionBranch => $collectionBranch, - itemnumber => $itemnumber, - ); +if ( $barcode ) { + my $item_from_barcode = Koha::Items->find({barcode => $barcode }); # How many times do we fetch this item?!? + if ( $item_from_barcode ) { + $itemnumber = $item_from_barcode->itemnumber; + my ( $holdingBranch, $collectionBranch ) = GetCollectionItemBranches( $itemnumber ); + if ( $holdingBranch and $collectionBranch ) { + $holdingBranch //= ''; + $collectionBranch //= $returnbranch; + if ( ! ( $holdingBranch eq $collectionBranch ) ) { + $template->param( + collectionItemNeedsTransferred => 1, + collectionBranch => $collectionBranch, + itemnumber => $itemnumber, + ); + } } } } -- 2.21.0 (Apple Git-122.2)