From ee6a69ce053f2e2135df8d4d0d41e8e3fe1abb05 Mon Sep 17 00:00:00 2001 From: Marcel de Rooy Date: Wed, 7 Dec 2022 13:27:02 +0000 Subject: [PATCH] Bug 32417: Allow NULL in biblionumber in $order->store Content-Type: text/plain; charset=utf-8 If we are cancelling an order and call DelBiblio, we should clear the biblionumber but not be crashing on it in ->store. The absence of the clear prevented the crash. One bug sometimes solves another one. Test plan: Create basket, order line. Delete order with biblio record. Verify result and logfile. Signed-off-by: Marcel de Rooy --- Koha/Acquisition/Order.pm | 2 ++ 1 file changed, 2 insertions(+) diff --git a/Koha/Acquisition/Order.pm b/Koha/Acquisition/Order.pm index d9161a3e9b..f6308d13e1 100644 --- a/Koha/Acquisition/Order.pm +++ b/Koha/Acquisition/Order.pm @@ -77,6 +77,7 @@ sub store { # if these parameters are missing, we can't continue for my $key (qw( basketno quantity biblionumber budget_id )) { + next if $key eq 'biblionumber' && ($self->orderstatus // q{}) eq 'cancelled'; # cancelled order might have biblionumber NULL croak "Cannot insert order: Mandatory parameter $key is missing" unless $self->$key; } @@ -158,6 +159,7 @@ sub cancel { payload => { biblio => $biblio, reason => $error } } ) if $error; + $self->biblionumber(undef) unless $error; # constraint cleared biblionumber in db already } else { -- 2.30.2