Bug 8842 - Plack and tools/holidays.pl
Summary: Plack and tools/holidays.pl
Status: CLOSED FIXED
Alias: None
Product: Koha
Classification: Unclassified
Component: Architecture, internals, and plumbing (show other bugs)
Version: 3.10
Hardware: All All
: P5 - low blocker (vote)
Assignee: Paul Poulain
QA Contact: Jonathan Druart
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2012-09-28 13:15 UTC by Paul Poulain
Modified: 2019-06-27 09:24 UTC (History)
3 users (show)

See Also:
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 (2.14 KB, patch)
2012-11-02 09:02 UTC, Paul Poulain
Details | Diff | Splinter Review
Bug 8842 fix Plack scoping in acquisition (3.34 KB, patch)
2012-11-02 09:20 UTC, Paul Poulain
Details | Diff | Splinter Review
Bug 8842 fix Plack scoping for holidays (2.20 KB, patch)
2012-11-02 11:46 UTC, Jared Camins-Esakov
Details | Diff | Splinter Review

Note You need to log in before you can comment on or make changes to this bug.
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