From 67513c6562b476b6ab0e218752c8bf4c145bb01f 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 (cherry picked from commit e7d886d388dc9825c6e93a158e19f7da60db145b) Signed-off-by: Lucas Gass (cherry picked from commit e03b542a18d20f00211721e3c2f200d7fc00c664) Signed-off-by: Arthur Suzuki --- 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 65d7b9d9a9..ab10697b79 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 44d6fb543c..b7df3c4087 100644 --- a/Koha/Hold.pm +++ b/Koha/Hold.pm @@ -611,6 +611,8 @@ expirationdate for holds. sub store { my ($self) = @_; + Koha::Exceptions::Hold::MissingPickupLocation->throw() unless $self->branchcode; + if ( !$self->in_storage ) { if ( C4::Context->preference('DefaultHoldExpirationdate') -- 2.39.5