From 71b7d5629878bd5616dbb1db263a8fd943d3f7b9 Mon Sep 17 00:00:00 2001 From: Galen Charlton Date: Mon, 30 Dec 2013 18:50:04 +0000 Subject: [PATCH] Bug 10277: (follow-up) if no userenv is set, act like a superlibrarian This patch fixes an error caught by t/db_dependent/Acquisition.t, and adjusts C4::Context::IsSuperLibrarian() to return true if no userenv is set. This is done on the basis that if no userenv is set, calls to C4::Context routines are being made from a command-line script, and if you have access to the command line of a running Koha instance, you implicitly already have better than superlibrarian access. Signed-off-by: Galen Charlton --- C4/Context.pm | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/C4/Context.pm b/C4/Context.pm index 9ff9352861..cee4a0f3ec 100644 --- a/C4/Context.pm +++ b/C4/Context.pm @@ -1245,8 +1245,11 @@ sub IsSuperLibrarian { my $userenv = C4::Context->userenv; unless ( $userenv and exists $userenv->{flags} ) { - carp("C4::Context->userenv not defined!"); - return 0; + # If we reach this without a user environment, + # assume that we're running from a command-line script, + # and act as a superlibrarian. + carp("C4::Context->userenv not defined!"); + return 1; } return $userenv->{flags} % 2; -- 2.39.5