From bd5f1d399652c08e93bf38577641d028c4d21a1d 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 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 Signed-off-by: Martin Renvoize --- Koha/Acquisition/Order.pm | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/Koha/Acquisition/Order.pm b/Koha/Acquisition/Order.pm index d9161a3e9b8..b9059b01326 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; } @@ -105,8 +106,11 @@ sub store { =head3 cancel $order->cancel( - { [ reason => $reason, - delete_biblio => $delete_biblio ] + { + [ + reason => $reason, + delete_biblio => $delete_biblio + ] } ); @@ -158,6 +162,7 @@ sub cancel { payload => { biblio => $biblio, reason => $error } } ) if $error; + $self->biblionumber(undef) unless $error; # constraint cleared biblionumber in db already } else { -- 2.38.1