Bug 14709: Do not access to C4::Context->userenv from the commandline

The script dies with
  Can't use an undefined value as a HASH reference at tools/export.pl
line 149.
if it is called from the command line.

This is introduced by bug 13040.

The C4::Context->userenv is not defined in this case.

Test plan:
Execute the script using the command line.
With the patch applies you should not get the error.

Signed-off-by: Joonas Kylmälä <j.kylmala@gmail.com>

Signed-off-by: Katrin Fischer <katrin.fischer.83@web.de>
Signed-off-by: Tomas Cohen Arazi <tomascohen@unc.edu.ar>
This commit is contained in:
Jonathan Druart 2015-08-24 10:07:37 +01:00 committed by Tomas Cohen Arazi
parent ce2ea94f30
commit 6ad59e7ab4

View file

@ -146,7 +146,7 @@ if ( C4::Context->preference("IndependentBranches")
@branch = ( C4::Context->userenv->{'branch'} );
}
# if stripping nonlocal items, use loggedinuser's branch
my $localbranch = C4::Context->userenv->{'branch'};
my $localbranch = C4::Context->userenv ? C4::Context->userenv->{'branch'} : undef;
my %branchmap = map { $_ => 1 } @branch; # for quick lookups