diff --git a/iNCIPit.cgi b/iNCIPit.cgi index cecd146..1fbf06b 100644 --- a/iNCIPit.cgi +++ b/iNCIPit.cgi @@ -511,16 +511,32 @@ sub item_cancelled { # we are the user agency $barcode .= $faidValue; my $copy = copy_from_barcode($barcode); + if (ref($copy) eq "HASH") { + if ($copy->{textcode} eq 'ASSET_COPY_NOT_FOUND') { + staff_log( $taidValue, $faidValue, "Bad Barcode Requested: ". $barcode ); + fail("cancel request on non-existent item"); + exit; + } + } fail( $copy->{textcode} . " $barcode" ) unless ( blessed $copy); my $r = cancel_hold($barcode); $r = delete_copy($copy); } else { # we are the item agency unless ( $conf->{behavior}->{no_item_agency_holds} =~ m/^y/i ) { + # Make sure the copy exists! + my $copy = copy_from_barcode($barcode); + # If copy does not exist, return failure + if (ref($copy) eq "HASH") { + if ($copy->{textcode} eq 'ASSET_COPY_NOT_FOUND') { + staff_log( $taidValue, $faidValue, "Bad Barcode Requested: ". $barcode ); + fail("cancel request on non-existent item"); + exit; + } + } # remove hold! my $r = cancel_hold($barcode); - # TODO: check for any errors or unexpected return values in $r - my $copy = copy_from_barcode($barcode); + fail( $copy->{textcode} . " $barcode" ) unless ( blessed $copy); $r = update_copy( $copy, 7 ); # set to reshelving (for wiggle room) # TODO: check for any errors or unexpected return values in $r