Bug 14153

Summary: Noisy warns in admin/transport-cost-matrix.pl
Product: Koha Reporter: Aleisha Amohia <aleisha>
Component: System AdministrationAssignee: Aleisha Amohia <aleisha>
Status: CLOSED FIXED QA Contact: Testopia <testopia>
Severity: minor    
Priority: P5 - low CC: brendan, f.demians, gmcharlt, jonathan.druart, julian.maurice
Version: unspecified   
Hardware: All   
OS: All   
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
Bug 14153: Galen Charlton's fix to warns
Bug 14153: Noisy warns in admin/transport-cost-matrix.pl
Bug 14153: Noisy warns in admin/transport-cost-matrix.pl

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.