From 480b2a302b8ce77344d0051d9c6a6e947cbbc59f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Marc=20V=C3=A9ron?= Date: Mon, 14 Dec 2015 15:43:57 +0100 Subject: [PATCH] Bug 14015 - Checkout: Fix software error if barcode '0' is given To reproduce the bug: - Go to Home > Circulation > Checkouts > [a patron] - Enter 0 (zero) in barcode field and hit Enter Result: Software error Can't use string ("1") as a HASH ref while "strict refs" in use at /usr/share/kohaclone/circ/circulation.pl line 473 To test: - Apply patch - Repeat steps above - Verify that the sofware error is gone and that you get a message as with other invalid barcodes. - Test with other values: '00', '000', existing barcode, barcode that does not exist - Test with empty barcode (for printing slip) - Search for regressions Note: I tried to create an item with barcode '0' to test that case as well, but it was not possible. Giving the possibility to create an item with barcode '0' is not in the scope of this bug. --- circ/circulation.pl | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/circ/circulation.pl b/circ/circulation.pl index 3748d97..c27232d 100755 --- a/circ/circulation.pl +++ b/circ/circulation.pl @@ -88,7 +88,9 @@ if (!C4::Context->userenv && !$branch){ } my $barcodes = []; -if ( my $barcode = $query->param('barcode') ) { +my $barcode = $query->param('barcode'); +# Barcode given by user could be '0' +if ( $barcode || $barcode eq '0' ) { $barcodes = [ $barcode ]; } else { my $filefh = $query->upload('uploadfile'); @@ -215,12 +217,13 @@ if( $onsite_checkout && !$duedatespec_allow ) { } # check and see if we should print -if ( @$barcodes == 0 && $print eq 'maybe' ) { +# but do not set to 'yes' if barcode given by user is '0' +if ( ( @$barcodes == 0 ) && ( ! @$barcodes eq '0') && ( $print eq 'maybe' ) ) { $print = 'yes'; } -my $inprocess = (@$barcodes == 0) ? '' : $query->param('inprocess'); -if ( @$barcodes == 0 && $charges eq 'yes' ) { +my $inprocess = ( (@$barcodes == 0 ) && ( ! @$barcodes eq '0') ) ? '' : $query->param('inprocess'); +if ( ( @$barcodes == 0 ) && ( ! @$barcodes eq '0' ) && $charges eq 'yes' ) { $template->param( PAYCHARGES => 'yes', borrowernumber => $borrowernumber -- 1.7.10.4