Bug 17294: Make reserves_stats.pl plack safe

Lot of errors are raised by this script under plack because of var scope
issues:

Variable "$ccodes" is not available at
/home/koha/src/reports/reserves_stats.pl line 337.
Variable "$locations" is not available at
/home/koha/src/reports/reserves_stats.pl line 338.
Variable "$itemtypes" is not available at
/home/koha/src/reports/reserves_stats.pl line 339.
Variable "$Bsort1" is not available at
/home/koha/src/reports/reserves_stats.pl line 344.
Variable "$Bsort2" is not available at
/home/koha/src/reports/reserves_stats.pl line 350.
Variable "@patron_categories" is not available at
/home/koha/src/reports/reserves_stats.pl line 356.

The lazy way to fix that is that reinit them from the subroutines they
are used.

Test plan:
Execute the report, after this patch applied you won't see the error in
the log.

Signed-off-by: Marc Véron <veron@veron.ch>

Signed-off-by: Katrin Fischer  <katrin.fischer@bsz-bw.de>

Signed-off-by: Kyle M Hall <kyle@bywatersolutions.com>
(cherry picked from commit f66cc4dfcc)
Signed-off-by: Frédéric Demians <f.demians@tamil.fr>
(cherry picked from commit 1ade46e5a4)
Signed-off-by: Julian Maurice <julian.maurice@biblibre.com>
This commit is contained in:
Jonathan Druart 2016-09-13 09:44:41 +01:00 committed by Julian Maurice
parent 853644230c
commit 70ca305311
1 changed files with 6 additions and 0 deletions

View File

@ -334,6 +334,12 @@ sub null_to_zzempty ($) {
}
sub display_value {
my ( $crit, $value ) = @_;
my $ccodes = GetKohaAuthorisedValues("items.ccode");
my $locations = GetKohaAuthorisedValues("items.location");
my $itemtypes = GetItemTypes();
my $authvalue = GetKohaAuthorisedValues("items.authvalue");
my $Bsort1 = GetAuthorisedValues("Bsort1");
my $Bsort2 = GetAuthorisedValues("Bsort2");
my $display_value =
( $crit =~ /ccode/ ) ? $ccodes->{$value}
: ( $crit =~ /location/ ) ? $locations->{$value}