From dc1c8fa74237a29e85f0437ecbcbbf3937935cdf Mon Sep 17 00:00:00 2001 From: Kyle M Hall Date: Thu, 25 Apr 2019 15:50:35 -0400 Subject: [PATCH] Bug 22778: Suggestions with no "suggester" can cause errors If one tries to modify a suggestion that has no suggester you will get the following error: Can't call method "lang" on an undefined value at /usr/share/koha/lib/C4/Suggestions.pm line 506 Koha assumes that every suggestion has a borrowernumber in suggestedby Test Plan: 1) Create a suggestion with an unpopulated suggestedby 2) Attempt to modify that suggestion 3) Note the error 4) Apply this patch 5) Restart all teh things 6) Attempt to modify that suggestion 7) No error! Signed-off-by: David Roberts --- C4/Suggestions.pm | 2 ++ 1 file changed, 2 insertions(+) diff --git a/C4/Suggestions.pm b/C4/Suggestions.pm index 8d5336063c..43ffe506e9 100644 --- a/C4/Suggestions.pm +++ b/C4/Suggestions.pm @@ -531,7 +531,9 @@ sub ModSuggestion { # fetch the entire updated suggestion so that we can populate the letter my $full_suggestion = GetSuggestion( $suggestion->{suggestionid} ); + my $patron = Koha::Patrons->find( $full_suggestion->{suggestedby} ); + return unless $patron; my $transport = (C4::Context->preference("FallbackToSMSIfNoEmail")) && ($patron->smsalertnumber) && (!$patron->email) ? 'sms' : 'email'; -- 2.11.0