Bug 8842

Summary: Plack and tools/holidays.pl
Product: Koha Reporter: Paul Poulain <paul.poulain>
Component: Architecture, internals, and plumbingAssignee: Paul Poulain <paul.poulain>
Status: CLOSED FIXED QA Contact: Jonathan Druart <jonathan.druart>
Severity: blocker    
Priority: P5 - low CC: chris, dpavlin, jonathan.druart
Version: 3.10   
Hardware: All   
OS: All   
Change sponsored?: --- Patch complexity: ---
Documentation contact: Documentation submission:
Text to go in the release notes:
Version(s) released in:
Attachments: Bug 8842 fix Plack scoping for holidays
Bug 8842 fix Plack scoping in acquisition
Bug 8842 fix Plack scoping for holidays

Description Paul Poulain 2012-09-28 13:15:25 UTC
Saving holidays (at least a range) does not work when you're using Plack.

In the logs you see:
Variable "$newoperation" is not available at /home/paul/koha.dev/koha-community/tools/newHolidays.pl line 86.
Variable "$branchcode" is not available at /home/paul/koha.dev/koha-community/tools/newHolidays.pl line 86.
Variable "$weekday" is not available at /home/paul/koha.dev/koha-community/tools/newHolidays.pl line 86.
Variable "$day" is not available at /home/paul/koha.dev/koha-community/tools/newHolidays.pl line 86.
Variable "$month" is not available at /home/paul/koha.dev/koha-community/tools/newHolidays.pl line 86.
Variable "$year" is not available at /home/paul/koha.dev/koha-community/tools/newHolidays.pl line 86.
Variable "$title" is not available at /home/paul/koha.dev/koha-community/tools/newHolidays.pl line 86.
Variable "$description" is not available at /home/paul/koha.dev/koha-community/tools/newHolidays.pl line 86.
Variable "@holiday_list" is not available at /home/paul/koha.dev/koha-community/tools/newHolidays.pl line 117.
Use of uninitialized value $sessiontype in string eq at /home/paul/koha.dev/koha-community/C4/Auth.pm line 705.


It means there is a sub that uses a variable that is global. When you use Plack, your script is "wrapped" into a larger sub. So all global variable become local and the $newoperation are no more available.

The probable solution is to replace

	($newoperation, $branchcode, $weekday, $day, $month, $year, $title, $description) = @_;  

by
my 	($newoperation, $branchcode, $weekday, $day, $month, $year, $title, $description) = @_;
Comment 1 Paul Poulain 2012-11-02 09:02:48 UTC Comment hidden (obsolete)
Comment 2 Paul Poulain 2012-11-02 09:03:19 UTC
Upgrading severity, it's a Blocker for Plack users
Comment 3 Paul Poulain 2012-11-02 09:20:18 UTC Comment hidden (obsolete)
Comment 4 Paul Poulain 2012-11-02 09:21:10 UTC
Comment on attachment 13187 [details] [review]
Bug 8842 fix Plack scoping in acquisition

oops... wrong bug, it's 8892, not 8842. Will attach this one to the correct bug
Comment 5 Jared Camins-Esakov 2012-11-02 11:46:38 UTC
Created attachment 13199 [details] [review]
Bug 8842 fix Plack scoping for holidays

the internal sub add_holiday uses some variables that are defined in the main script, usual fix

Signed-off-by: Jared Camins-Esakov <jcamins@cpbibliography.com>
Comment 6 Jonathan Druart 2012-11-05 10:52:39 UTC
QA Comment:

This patch fixes the issue using plack and does not introduce regression.

Marked as Passed QA.
Comment 7 Jared Camins-Esakov 2012-11-05 13:50:16 UTC
This patch has been pushed to master.
Comment 8 Paul Poulain 2012-11-05 15:57:58 UTC
Patch pushed to branch 3.10.x
Comment 9 Chris Cormack 2013-04-22 08:27:37 UTC
Released in 3.10.0