Bug 14153 - Noisy warns in admin/transport-cost-matrix.pl
Summary: Noisy warns in admin/transport-cost-matrix.pl
Status: CLOSED FIXED
Alias: None
Product: Koha
Classification: Unclassified
Component: System Administration (show other bugs)
Version: unspecified
Hardware: All All
: P5 - low minor
Assignee: Aleisha Amohia
QA Contact: Testopia
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2015-05-06 04:46 UTC by Aleisha Amohia
Modified: 2017-06-14 22:10 UTC (History)
5 users (show)

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


Attachments
Bug 14153: Noisy warns in admin/transport-cost-matrix.pl (1.22 KB, patch)
2015-05-06 04:54 UTC, Aleisha Amohia
Details | Diff | Splinter Review
Bug 14153: Galen Charlton's fix to warns (1.09 KB, patch)
2015-12-13 22:25 UTC, Aleisha Amohia
Details | Diff | Splinter Review
Bug 14153: Noisy warns in admin/transport-cost-matrix.pl (1.15 KB, patch)
2015-12-28 16:34 UTC, Jonathan Druart
Details | Diff | Splinter Review
Bug 14153: Noisy warns in admin/transport-cost-matrix.pl (1.21 KB, patch)
2015-12-30 04:18 UTC, Brendan Gallagher
Details | Diff | Splinter Review

Note You need to log in before you can comment on or make changes to this bug.
Description Aleisha Amohia 2015-05-06 04:46:31 UTC
my $update = $input->param('op') eq 'set-cost-matrix';

The above code (line 45) causes a warn 'Use of unintialized value in string eq'
Comment 1 Aleisha Amohia 2015-05-06 04:54:10 UTC Comment hidden (obsolete)
Comment 2 Galen Charlton 2015-12-05 16:22:43 UTC
Comment on attachment 38880 [details] [review]
Bug 14153: Noisy warns in admin/transport-cost-matrix.pl

Review of attachment 38880 [details] [review]:
-----------------------------------------------------------------

::: admin/transport-cost-matrix.pl
@@ +42,4 @@
>                              });
>  my $use_transport_cost_matrix = C4::Context->preference("UseTransportCostMatrix");
>  
> +my $update = {$input->param('op')} eq 'set-cost-matrix';

Adding the curly brace here means that the code is trying to create an anonymous hash containing the contents of $input->param('op'), and that can't be compared to the scalar value 'set-cost-matrix'. Also, when trying to update an entry in the table, an "Odd number of elements in anonymous hash" error is thrown.

Something like this would do the trick:

my $update = ( $input->param('op') // '' ) eq 'set-cost-matrix';
Comment 3 Aleisha Amohia 2015-12-13 22:25:28 UTC Comment hidden (obsolete)
Comment 4 Jonathan Druart 2015-12-28 16:34:08 UTC Comment hidden (obsolete)
Comment 5 Jonathan Druart 2015-12-28 16:34:29 UTC
Trivial, skipping QA.
Comment 6 Brendan Gallagher 2015-12-30 04:18:21 UTC
Created attachment 46065 [details] [review]
Bug 14153: Noisy warns in admin/transport-cost-matrix.pl

To test:

1) Go to Admin -> Transport cost matrix
2) Notice the warns in the error log
3) Apply the patch and refresh page
4) Notice page still works but no warns in error log

Signed-off-by: Jonathan Druart <jonathan.druart@bugs.koha-community.org>
Amended patch: Init a $op variable, if it must be reused later.

Signed-off-by: Brendan A Gallagher <brendan@bywatersolutions.com>
Comment 7 Brendan Gallagher 2015-12-30 04:18:38 UTC
Pushed to Master - thanks
Comment 8 Jonathan Druart 2015-12-30 11:15:17 UTC
(In reply to Brendan Gallagher from comment #6)
> Signed-off-by: Jonathan Druart <jonathan.druart@bugs.koha-community.org>
> Amended patch: Init a $op variable, if it must be reused later.

Note that I have not made this change finally.
Comment 9 Julian Maurice 2015-12-31 09:16:59 UTC
Patch pushed to 3.22.x, will be in 3.22.2
Comment 10 Frédéric Demians 2015-12-31 18:28:53 UTC
This patch has been pushed to 3.20.x, will be in 3.20.8.