From 8ac3a5beec444c443cc9af65187f8dfbcfbe4f47 Mon Sep 17 00:00:00 2001 From: Lari Taskula Date: Tue, 22 Feb 2022 14:13:58 +0000 Subject: [PATCH] Bug 22321: Fix store() crash when modifying borrowernumber of a new ILL request To test: 1. prove t/db_dependent/Illrequests.t Signed-off-by: Magnus Enger Tried to change the borrowernumber connected to an ILL request and checked that the associated hold was updated to the new patron as well. Signed-off-by: Katrin Fischer Signed-off-by: Martin Renvoize Signed-off-by: Tomas Cohen Arazi --- Koha/Illrequest.pm | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/Koha/Illrequest.pm b/Koha/Illrequest.pm index c60c1dcdf9..723b11843e 100644 --- a/Koha/Illrequest.pm +++ b/Koha/Illrequest.pm @@ -1761,7 +1761,7 @@ sub store { my %updated_columns = $self->_result->get_dirty_columns; my @holds; - if( defined $updated_columns{'borrowernumber'} and + if( $self->in_storage and defined $updated_columns{'borrowernumber'} and Koha::Patrons->find( $updated_columns{'borrowernumber'} ) ) { # borrowernumber has changed @@ -1769,7 +1769,7 @@ sub store { @holds = Koha::Holds->search( { borrowernumber => $old_illreq->borrowernumber, biblionumber => $self->biblio_id, - } )->as_list; + } )->as_list if $old_illreq; } my $ret = $self->SUPER::store; -- 2.39.5