Summary: | Noisy warns in admin/preferences.pl | ||
---|---|---|---|
Product: | Koha | Reporter: | Aleisha Amohia <aleisha> |
Component: | System Administration | Assignee: | Mark Tompsett <mtompset> |
Status: | CLOSED FIXED | QA Contact: | Testopia <testopia> |
Severity: | minor | ||
Priority: | P5 - low | CC: | bgkriegel, gmcharlt, mtompset, tomascohen |
Version: | Main | ||
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 14145: Noisy warns in admin/preferences.pl
Bug 14145: Noisy warns in admin/preferences.pl on Enhanced Content tab Bug 14145: Nicer counter-patch [SIGNED-OFF] Bug 14145: Noisy warns in admin/preferences.pl Bug 14145: Noisy warns in admin/preferences.pl |
Description
Aleisha Amohia
2015-05-05 05:02:02 UTC
Created attachment 38838 [details] [review] Bug 14145: Noisy warns in admin/preferences.pl This patch silences the warns on lines 116 and 121 by referring to the chunk variable name (type) rather than what I assume is the string 'multiple'. I don't know that this is the best solution for this, but the warns are gone and the page seems to work still. To test: 1) Go to Admin -> System Preferences and click on the OPAC tab 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 Created attachment 38839 [details] [review] Bug 14145: Noisy warns in admin/preferences.pl on Enhanced Content tab 'Use of uninitialized value $value in split' on line 109, fixed by setting $value to an empty string. To test: 1) Go to Admin -> System preferences 2) Click on Enhanced content tab 3) Notice warns in error log 4) Apply patch and refresh page 5) Notice page still works but no warns in error log Created attachment 38999 [details] [review] Bug 14145: Nicer counter-patch The problem with the odd number of hashes happens when not everything is selected. The grep returns undef, because it isn't found in @values. By turning the grep into a ternary-operator truth value, we can set a value (1 or 0) expressly. The next problem is when nothing is selected in these multiple lists, $value is undefined, so you can't split it. By splitting the definition of @values from the actual splitting, we can split only if $value is defined, thus eliminating the warning message. TEST PLAN --------- 1) back up your koha error log file 2) blank your koha error log file 3) log in to the staff client 4) Home -> Koha administration -> Global system preferences 5) Click on every tab, EXCEPT local use. 6) notice the koha error log file has warnings. 7) blank the koha error log file again 8) apply this patch 9) Click on every tab, EXCEPT local use, again. 10) notice the koha error log file has no warnings. 11) koha qa test tools. To sign off this bug either: 1) sign off the first two and obsolete my counter patch OR 2) sign off my counter patch and obsolete the first two. Though, I personally am confused by some of the changes in the first two patches, so that is why I wrote the counter patch. Comment on attachment 38838 [details] [review] Bug 14145: Noisy warns in admin/preferences.pl Review of attachment 38838 [details] [review]: ----------------------------------------------------------------- ::: admin/preferences.pl @@ +46,4 @@ > my $tab_template = C4::Templates::gettemplate( 'admin/preferences/' . $tab . '.pref', 'intranet', $input ); > > my $active_currency = GetCurrency(); > + my $local_currency;; Double ;;'s? @@ +112,5 @@ > sort { $a->{'text'} cmp $b->{'text'} } > map { > my $option_value = $_; > { > + text => $options{type}->{$option_value}, This works, because the $options{type} doesn't exist, so two undefs reduces the list size by an even number for the failed grep too. There is no reason to change 'multiple' to 'type'. Comment on attachment 38839 [details] [review] Bug 14145: Noisy warns in admin/preferences.pl on Enhanced Content tab Review of attachment 38839 [details] [review]: ----------------------------------------------------------------- ::: admin/preferences.pl @@ +62,4 @@ > > my $name = $options{'pref'}; > my $chunk = { name => $name, value => $value, type => $options{'type'} || 'input', class => $options{'class'} };; > + $value //= ''; If $value is undef, then the question is what else is undef in the list above? $options{'pref'}? $options{'class'}? Because otherwise line 64 would be barfing errors too about uneven lists. Perhaps there is something here to fix? Neither my counter patch nor this would fix it. Created attachment 39051 [details] [review] [SIGNED-OFF] Bug 14145: Noisy warns in admin/preferences.pl The problem with the odd number of hashes happens when not everything is selected. The grep returns undef, because it isn't found in @values. By turning the grep into a ternary-operator truth value, we can set a value (1 or 0) expressly. The next problem is when nothing is selected in these multiple lists, $value is undefined, so you can't split it. By splitting the definition of @values from the actual splitting, we can split only if $value is defined, thus eliminating the warning message. TEST PLAN --------- 1) back up your koha error log file 2) blank your koha error log file 3) log in to the staff client 4) Home -> Koha administration -> Global system preferences 5) Click on every tab, EXCEPT local use. 6) notice the koha error log file has warnings. 7) blank the koha error log file again 8) apply this patch 9) Click on every tab, EXCEPT local use, again. 10) notice the koha error log file has no warnings. 11) koha qa test tools. Signed-off-by: Bernardo Gonzalez Kriegel <bgkriegel@gmail.com> I like more this version Works as described No koha-qa errors Created attachment 39384 [details] [review] Bug 14145: Noisy warns in admin/preferences.pl The problem with the odd number of hashes happens when not everything is selected. The grep returns undef, because it isn't found in @values. By turning the grep into a ternary-operator truth value, we can set a value (1 or 0) expressly. The next problem is when nothing is selected in these multiple lists, $value is undefined, so you can't split it. By splitting the definition of @values from the actual splitting, we can split only if $value is defined, thus eliminating the warning message. TEST PLAN --------- 1) back up your koha error log file 2) blank your koha error log file 3) log in to the staff client 4) Home -> Koha administration -> Global system preferences 5) Click on every tab, EXCEPT local use. 6) notice the koha error log file has warnings. 7) blank the koha error log file again 8) apply this patch 9) Click on every tab, EXCEPT local use, again. 10) notice the koha error log file has no warnings. 11) koha qa test tools. Signed-off-by: Bernardo Gonzalez Kriegel <bgkriegel@gmail.com> I like more this version Works as described No koha-qa errors Signed-off-by: Jonathan Druart <jonathan.druart@koha-community.org> To reproduce: go on the OPAC tab, OpacAdvSearchMoreOptions or OpacAdvSearchOptions should not have all options selected. Patch pushed to master. Thanks Mark! |