From 02b3f759e771b371a49eb6fe4b788e5a79abff19 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 --- 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.20.1