From 6f756b7c234d393895abf3790554cad202874f73 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 Signed-off-by: David Nind Signed-off-by: Tomas Cohen Arazi (cherry picked from commit d9186728919a1a41d56c4c8686e0197c746f7fa1) 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 d9161a3e9b..b9059b0132 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.39.5