Bug 14598: (QA followup) Don't die on bad barcode
authorKyle M Hall <kyle@bywatersolutions.com>
Mon, 27 Jul 2015 15:16:56 +0000 (11:16 -0400)
committerJulian Maurice <julian.maurice@biblibre.com>
Wed, 30 Nov 2016 12:48:05 +0000 (13:48 +0100)
Signed-off-by: Tomas Cohen Arazi <tomascohen@theke.io>

Signed-off-by: Kyle M Hall <kyle@bywatersolutions.com>

Signed-off-by: Kyle M Hall <kyle@bywatersolutions.com>
Signed-off-by: Tomas Cohen Arazi <tomascohen@gmail.com>

Signed-off-by: Marcel de Rooy <m.de.rooy@rijksmuseum.nl>

Signed-off-by: Kyle M Hall <kyle@bywatersolutions.com>
(cherry picked from commit 34eb4c1fa95ea14047413436b8df42299d029ca4)
Signed-off-by: Julian Maurice <julian.maurice@biblibre.com>

C4/Circulation.pm

index 982ece7..28a481d 100644 (file)
@@ -1827,17 +1827,17 @@ sub AddReturn {
     my $stat_type = 'return';
 
     # get information on item
-    my $item       = GetItem( undef, $barcode )
-        or die "GetItem( undef, $barcode ) failed";
+    my $item = GetItem( undef, $barcode );
+    unless ($item) {
+        return ( 0, { BadBarcode => $barcode } );    # no barcode means no item or borrower.  bail out.
+    }
+
     my $itemnumber = $item->{ itemnumber };
     my $biblio = GetBiblioData( $item->{ biblionumber } );
     my $itemtype   = ( C4::Context->preference("item-level_itypes") )
                         ? $item->{ itype }
                         : $biblio->{ itemtype };
 
-    unless ($itemnumber) {
-        return (0, { BadBarcode => $barcode }); # no barcode means no item or borrower.  bail out.
-    }
     my $issue  = GetItemIssue($itemnumber);
     if ($issue and $issue->{borrowernumber}) {
         $borrower = C4::Members::GetMemberDetails($issue->{borrowernumber})