Bug 22675: Fix SCO behaviour on non-existent barcodes
authorTomas Cohen Arazi <tomascohen@theke.io>
Tue, 9 Apr 2019 18:59:14 +0000 (15:59 -0300)
committerNick Clemens <nick@bywatersolutions.com>
Wed, 10 Apr 2019 20:07:52 +0000 (20:07 +0000)
Bug 21206 replaced GetItem for Koha::Items->find, and introduced this
problem. This patch verifies $item is defined before attempting to use
its methods.

To test:
- Log into SCO
- Type an invalid barcode
=> FAIL: Things explode :-/
- Apply this patch, reload
- Type an invalid barcode
=> SUCCESS: A nice error message is displayed :-D
- Sign off :-D

Signed-off-by: Liz Rea <wizzyrea@gmail.com>

Signed-off-by: Katrin Fischer <katrin.fischer.83@web.de>

Signed-off-by: Nick Clemens <nick@bywatersolutions.com>

opac/sco/sco-main.pl

index 7fd6ee8..a303524 100755 (executable)
@@ -158,11 +158,12 @@ elsif ( $patron && ( $op eq 'checkout' || $op eq 'renew' ) ) {
     if (scalar keys %$impossible) {
 
         my $issue_error = (keys %$impossible)[0]; # FIXME This is wrong, we assume only one error and keys are not ordered
+        my $title = ( $item ) ? $item->biblio->title : '';
 
         $template->param(
             impossible                => $issue_error,
             "circ_error_$issue_error" => 1,
-            title                     => $item->biblio->title, # FIXME Need to be backport! GetItem did not return the biblio's title
+            title                     => $title,
             hide_main                 => 1,
         );
         if ($issue_error eq 'DEBT') {