From e7d886d388dc9825c6e93a158e19f7da60db145b Mon Sep 17 00:00:00 2001 From: Nick Clemens Date: Fri, 1 Jul 2022 14:44:09 +0000 Subject: [PATCH] Bug 31086: Throw an exception when a hold is stored with no branchcode To test: 1 - Apply first 2 patches 2 - On staff client, find a biblio, place hold, select a patron 3 - Before creating hold, right click on 'Pickup location' 4 - Inspect the element 5 - In the console find the top
  • for pickup, and right click 6 - Select 'Delete node' 7 - Save hold 8 - You get an exception/error Signed-off-by: David Nind Signed-off-by: Martin Renvoize Signed-off-by: Tomas Cohen Arazi --- Koha/Exceptions/Hold.pm | 4 ++++ Koha/Hold.pm | 2 ++ 2 files changed, 6 insertions(+) diff --git a/Koha/Exceptions/Hold.pm b/Koha/Exceptions/Hold.pm index 8538963b96..b09dcd65b5 100644 --- a/Koha/Exceptions/Hold.pm +++ b/Koha/Exceptions/Hold.pm @@ -31,6 +31,10 @@ use Exception::Class ( 'Koha::Exceptions::Hold::InvalidPickupLocation' => { isa => 'Koha::Exceptions::Hold', description => 'The supplied pickup location is not valid' + }, + 'Koha::Exceptions::Hold::MissingPickupLocation' => { + isa => 'Koha::Exceptions::Hold', + description => 'You must supply a pickup location when placing a hold' } ); diff --git a/Koha/Hold.pm b/Koha/Hold.pm index be5970cbd4..68d0c8581d 100644 --- a/Koha/Hold.pm +++ b/Koha/Hold.pm @@ -713,6 +713,8 @@ expirationdate for holds. sub store { my ($self) = @_; + Koha::Exceptions::Hold::MissingPickupLocation->throw() unless $self->branchcode; + if ( !$self->in_storage ) { if ( ! $self->expirationdate && $self->patron_expiration_date ) { $self->expirationdate($self->patron_expiration_date); -- 2.39.5