From d2d784a917d64ce982fdf8c20ac2a5653b6b037f Mon Sep 17 00:00:00 2001 From: Mark Tompsett Date: Fri, 14 Jul 2017 14:15:20 +0000 Subject: [PATCH] Bug 18942: Internal Server Error symptomatic of using system user TEST PLAN --------- 1) sudo koha-shell -c bash kohadev 2) prove -v t/Budgets/CanUserUseBudget.t -- works 3) prove -v t/Budgets/CanUserModifyBudget.t -- works 4) exit 5) git bz apply 18942 -- interactive just the test patch 6) repeat steps 1-4 -- prove fails (similar message with 919 in comment #0) 7) git bz apply 18942 -- interactive just the actual fix 8) repeat steps 1-4 -- works 9) run koha qa test tools Signed-off-by: Lee Jamison Signed-off-by: Tomas Cohen Arazi Signed-off-by: Jonathan Druart --- C4/Budgets.pm | 14 ++++++++++++-- 1 file changed, 12 insertions(+), 2 deletions(-) diff --git a/C4/Budgets.pm b/C4/Budgets.pm index f05d234781..05f7ca5640 100644 --- a/C4/Budgets.pm +++ b/C4/Budgets.pm @@ -916,7 +916,12 @@ sub CanUserUseBudget { my ($borrower, $budget, $userflags) = @_; if (not ref $borrower) { - $borrower = Koha::Patrons->find( $borrower )->unblessed; + $borrower = Koha::Patrons->find( $borrower ); + if ( $borrower ) { + $borrower = $borrower->unblessed; + } else { + return 0; + } } if (not ref $budget) { $budget = GetBudget($budget); @@ -999,7 +1004,12 @@ sub CanUserModifyBudget { my ($borrower, $budget, $userflags) = @_; if (not ref $borrower) { - $borrower = Koha::Patrons->find( $borrower )->unblessed; + $borrower = Koha::Patrons->find( $borrower ); + if ( $borrower ) { + $borrower = $borrower->unblessed; + } else { + return 0; + } } if (not ref $budget) { $budget = GetBudget($budget); -- 2.39.5