From 0e9bbcb9131bafcaf1605a9b843271cfb1903077 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 --- Koha/Illrequest.pm | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/Koha/Illrequest.pm b/Koha/Illrequest.pm index ae82921a05..0805111538 100644 --- a/Koha/Illrequest.pm +++ b/Koha/Illrequest.pm @@ -1637,7 +1637,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 @@ -1645,7 +1645,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.30.2