Bug 19493 - Remove few warnings from circulation.pl
Summary: Remove few warnings from circulation.pl
Status: CLOSED FIXED
Alias: None
Product: Koha
Classification: Unclassified
Component: Architecture, internals, and plumbing (show other bugs)
Version: master
Hardware: All All
: P5 - low normal (vote)
Assignee: Marcel de Rooy
QA Contact: Testopia
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2017-10-19 07:44 UTC by Marcel de Rooy
Modified: 2018-06-04 20:18 UTC (History)
1 user (show)

See Also:
Change sponsored?: ---
Patch complexity: Trivial patch
Documentation contact:
Documentation submission:
Text to go in the release notes:
Version(s) released in:


Attachments
Bug 19493: Remove few warnings from circulation.pl (2.75 KB, patch)
2017-10-19 07:47 UTC, Marcel de Rooy
Details | Diff | Splinter Review
Bug 19493: Remove few warnings from circulation.pl (2.77 KB, patch)
2017-10-26 12:25 UTC, Nick Clemens
Details | Diff | Splinter Review
Bug 19493: Force scalar context to prevent future error (1.53 KB, patch)
2017-10-27 15:38 UTC, Jonathan Druart
Details | Diff | Splinter Review

Note You need to log in before you can comment on or make changes to this bug.
Description Marcel de Rooy 2017-10-19 07:44:47 UTC
If you click Submit on the staff home page without entering a cardnumber, you will find these warnings in the log:
Problem = a value of override_high_holds has been passed to param without key at /usr/share/koha/masterclone/C4/Templates.pm line 137.
Problem = a value of nopermission has been passed to param without key at /usr/share/koha/masterclone/C4/Templates.pm line 137.
Use of uninitialized value $val in concatenation (.) or string at /usr/share/koha/masterclone/C4/Templates.pm line 137.
Problem = a value of  has been passed to param without key at /usr/share/koha/masterclone/C4/Templates.pm line 137.

Cause is this call to $template->param:
$template->param(
     CircAutocompl             => C4::Context->preference("CircAutocompl"),
     debarments                => GetDebarments({ borrowernumber => $borrowernumber }),
     todaysdate                => output_pref( { dt => dt_from_string()->set(hour => 23)->set(minute => 59), dateformat => 'sql' } ),
    has_modifications         => $has_modifications,
     override_high_holds       => $override_high_holds,
     nopermission              => scalar $query->param('nopermission'),

In this specific case GetDebarments returns undef in list context (empty list),
so all items in the list shift one place.
Either we should force GetDebarments to return []; or we force scalar context in a construction like this.

Note: The calls in memberentry.pl and moremember.pl are not affected.
Comment 1 Marcel de Rooy 2017-10-19 07:47:15 UTC
Created attachment 68288 [details] [review]
Bug 19493: Remove few warnings from circulation.pl

If you click Submit on the staff home page without entering a cardnumber, you will find these warnings in the log:
Problem = a value of override_high_holds has been passed to param without key at /usr/share/koha/masterclone/C4/Templates.pm line 137.
Problem = a value of nopermission has been passed to param without key at /usr/share/koha/masterclone/C4/Templates.pm line 137.
Use of uninitialized value $val in concatenation (.) or string at /usr/share/koha/masterclone/C4/Templates.pm line 137.
Problem = a value of  has been passed to param without key at /usr/share/koha/masterclone/C4/Templates.pm line 137.

Cause is this call to $template->param:
$template->param(
     CircAutocompl             => C4::Context->preference("CircAutocompl"),
     debarments                => GetDebarments({ borrowernumber => $borrowernumber }),
     todaysdate                => output_pref( { dt => dt_from_string()->set(hour => 23)->set(minute => 59), dateformat => 'sql' } ),
    has_modifications         => $has_modifications,
     override_high_holds       => $override_high_holds,
     nopermission              => scalar $query->param('nopermission'),

In this specific case GetDebarments returns undef in list context (empty list),
so all items in the list shift one place.
Either we should force GetDebarments to return []; or we force scalar context in a construction like this. This patch does the last thing.

Note: The calls in memberentry.pl and moremember.pl are not affected.

Test plan:
[1] Do not apply. Click Submit without cardnumber. Check the log.
[2] Apply. Click Submit again without cardnumber. Check log.

Signed-off-by: Marcel de Rooy <m.de.rooy@rijksmuseum.nl>
Comment 2 Marcel de Rooy 2017-10-19 07:48:52 UTC
Moving to SO: super trivial.
Comment 3 Nick Clemens 2017-10-26 12:25:56 UTC
Created attachment 68599 [details] [review]
Bug 19493: Remove few warnings from circulation.pl

If you click Submit on the staff home page without entering a cardnumber, you will find these warnings in the log:
Problem = a value of override_high_holds has been passed to param without key at /usr/share/koha/masterclone/C4/Templates.pm line 137.
Problem = a value of nopermission has been passed to param without key at /usr/share/koha/masterclone/C4/Templates.pm line 137.
Use of uninitialized value $val in concatenation (.) or string at /usr/share/koha/masterclone/C4/Templates.pm line 137.
Problem = a value of  has been passed to param without key at /usr/share/koha/masterclone/C4/Templates.pm line 137.

Cause is this call to $template->param:
$template->param(
     CircAutocompl             => C4::Context->preference("CircAutocompl"),
     debarments                => GetDebarments({ borrowernumber => $borrowernumber }),
     todaysdate                => output_pref( { dt => dt_from_string()->set(hour => 23)->set(minute => 59), dateformat => 'sql' } ),
    has_modifications         => $has_modifications,
     override_high_holds       => $override_high_holds,
     nopermission              => scalar $query->param('nopermission'),

In this specific case GetDebarments returns undef in list context (empty list),
so all items in the list shift one place.
Either we should force GetDebarments to return []; or we force scalar context in a construction like this. This patch does the last thing.

Note: The calls in memberentry.pl and moremember.pl are not affected.

Test plan:
[1] Do not apply. Click Submit without cardnumber. Check the log.
[2] Apply. Click Submit again without cardnumber. Check log.

Signed-off-by: Marcel de Rooy <m.de.rooy@rijksmuseum.nl>

Signed-off-by: Nick Clemens <nick@bywatersolutions.com>
Comment 4 Jonathan Druart 2017-10-27 15:38:03 UTC
Created attachment 68755 [details] [review]
Bug 19493: Force scalar context to prevent future error

If someone decide the reuse the template->param statement to pass values
to the template, we will get the same issue.
Comment 5 Jonathan Druart 2017-10-27 17:17:25 UTC
Pushed to master for 17.11, thanks to everybody involved!