From e13770ad11b4b504413ef020770cd15e8ee55bbc Mon Sep 17 00:00:00 2001 From: Lari Taskula Date: Tue, 12 Nov 2019 12:18:27 +0000 Subject: [PATCH] Bug 24016: manager_id in Koha::Patron::Message->store should not depend on userenv alone MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit Koha::Patron::Message->store has this my $userenv = C4::Context->userenv; $self->manager_id( $userenv ? $userenv->{number} : undef); This breaks in REST API when userenv is not set. Let API user pass manager_id without relying on C4::Context->userenv. To test: 1. prove t/db_dependent/Koha/Patron/Messages.t 2. Observe success Sponsored-by: Koha-Suomi Oy Signed-off-by: Maryse Simard Signed-off-by: Joonas Kylmälä Signed-off-by: Martin Renvoize Signed-off-by: Joy Nelson (cherry picked from commit 49eac22b1f977b439e5d3f8f313dee3164719b60) Signed-off-by: Lucas Gass --- Koha/Patron/Message.pm | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/Koha/Patron/Message.pm b/Koha/Patron/Message.pm index ea5b9dc55b..838378011b 100644 --- a/Koha/Patron/Message.pm +++ b/Koha/Patron/Message.pm @@ -49,8 +49,10 @@ sub store { and $self->message_type and $self->branchcode; - my $userenv = C4::Context->userenv; - $self->manager_id( $userenv ? $userenv->{number} : undef); + unless (defined $self->manager_id) { + my $userenv = C4::Context->userenv; + $self->manager_id( $userenv ? $userenv->{number} : undef); + } C4::Log::logaction( "MEMBERS", "ADDCIRCMESSAGE", $self->borrowernumber, $self->message ) if C4::Context->preference("BorrowersLog"); -- 2.39.5