[Bug 39101] New: warning: "sort (...) interpreted as function" when running updatedatabase
https://bugs.koha-community.org/bugzilla3/show_bug.cgi?id=39101 Bug ID: 39101 Summary: warning: "sort (...) interpreted as function" when running updatedatabase Change sponsored?: --- Product: Koha Version: Main Hardware: All OS: All Status: NEW Severity: normal Priority: P5 - low Component: Installation and upgrade (command-line installer) Assignee: koha-bugs@lists.koha-community.org Reporter: victor@tuxayo.net QA Contact: testopia@bugs.koha-community.org CC: tomascohen@gmail.com sort (...) interpreted as function at /kohadevbox/koha/installer/data/mysql/updatedatabase.pl line 25950. It starts happening after that commit: d659526b5a Bug 38664: Tidy the whole codebase A more minimal example can be reproduced: ``` my $var_with_long_name_1 = "2019-10-30"; my $var_with_long_name_2 = "2005-01-10"; my $var_with_long_name_3 = "2010-02-01"; # no warning my ($max_value1) = sort ( $var_with_long_name_1, $var_with_long_name_2, $var_with_long_name_3 ); warn $max_value1; # sort (...) interpreted as function my ($max_value2) = sort ( $var_with_long_name_1, $var_with_long_name_2, $var_with_long_name_3 ); # sort (...) interpreted as function my ($max_value3) = sort ( $var_with_long_name_1, $var_with_long_name_2, $var_with_long_name_3 ); # sort (...) interpreted as function my ($max_value4) = sort ( $var_with_long_name_1, $var_with_long_name_2, $var_with_long_name_3 ); ``` perl -w test.pl sort (...) interpreted as function at test.pl line 11. sort (...) interpreted as function at test.pl line 15. sort (...) interpreted as function at test.pl line 20. 2005-01-10 at test.pl line 8. So somehow perl doesn't like when here the args aren't in the same line. And the sorting is ascending so it gets the min value when it seems the intent was to get the max value! https://gitlab.com/koha-community/Koha/-/blob/93eda45a9e6d492161096a0536a195...
my ($max_date) = sort ( $suggestion->{manageddate} || (), $suggestion->{accepteddate} || (), $suggestion->{rejecteddate} || () );
-- You are receiving this mail because: You are watching all bug changes. You are the assignee for the bug.
https://bugs.koha-community.org/bugzilla3/show_bug.cgi?id=39101 --- Comment #1 from Victor Grousset/tuxayo <victor@tuxayo.net> --- So I guess it can be fixed either by looking at that weird perl behavior. Or by fixing that old DB rev so it actually gets the max_date. Assuming that's correct functionally. A fix might change the code enough to avoid the weird warning. Just reversing the sort with { $b cmp $a } avoids the warning ^^" my ($max_value2) = sort { $b cmp $a } ( $var_with_long_name_1, $var_with_long_name_2, $var_with_long_name_3 ); ---- Should severity be major because it might cause doubt on whether upgrade failed or worked? -- You are receiving this mail because: You are watching all bug changes. You are the assignee for the bug.
https://bugs.koha-community.org/bugzilla3/show_bug.cgi?id=39101 David Cook <dcook@prosentient.com.au> changed: What |Removed |Added ---------------------------------------------------------------------------- CC| |dcook@prosentient.com.au Depends on| |38664 Referenced Bugs: https://bugs.koha-community.org/bugzilla3/show_bug.cgi?id=38664 [Bug 38664] Tidy the whole codebase -- You are receiving this mail because: You are the assignee for the bug. You are watching all bug changes.
https://bugs.koha-community.org/bugzilla3/show_bug.cgi?id=39101 Jonathan Druart <jonathan.druart@gmail.com> changed: What |Removed |Added ---------------------------------------------------------------------------- Resolution|--- |DUPLICATE Status|NEW |RESOLVED CC| |jonathan.druart@gmail.com --- Comment #2 from Jonathan Druart <jonathan.druart@gmail.com> --- Done in bug 38664: Fix updatedatabase.pl *** This bug has been marked as a duplicate of bug 38664 *** -- You are receiving this mail because: You are the assignee for the bug. You are watching all bug changes.
https://bugs.koha-community.org/bugzilla3/show_bug.cgi?id=39101 --- Comment #3 from Victor Grousset/tuxayo <victor@tuxayo.net> --- Thanks for the fix in bug 38664 comment 48 :)
my ($max_date) = sort { $a cmp $b } (
Note that with "{ $a cmp $b} " it's still sorting ascendingly which would give a min_date and not max_date. But we would have to do more testing on that old db rev from 2019. Whose wrongness got unnoticed to this day. So I guess we can not bother with it. -- You are receiving this mail because: You are the assignee for the bug. You are watching all bug changes.
https://bugs.koha-community.org/bugzilla3/show_bug.cgi?id=39101 --- Comment #4 from Jonathan Druart <jonathan.druart@gmail.com> --- well yes, indeed. I was focus on submitting something that won't change the behaviour and didn't notice that the behaviour was wrong. At least there is no change :D IMO it's too late to change that, especially if nobody noticed yet... -- You are receiving this mail because: You are the assignee for the bug. You are watching all bug changes.
https://bugs.koha-community.org/bugzilla3/show_bug.cgi?id=39101 Bug 39101 depends on bug 38664, which changed state. Bug 38664 Summary: Tidy the whole codebase https://bugs.koha-community.org/bugzilla3/show_bug.cgi?id=38664 What |Removed |Added ---------------------------------------------------------------------------- Status|Needs documenting |RESOLVED Resolution|--- |FIXED -- You are receiving this mail because: You are watching all bug changes. You are the assignee for the bug.
participants (1)
-
bugzilla-daemon@bugs.koha-community.org