[Bug 25516] New: Item/pickup_locations wantarray removed, so dies on Perl >=5.24 where "autoderef" feature absent
https://bugs.koha-community.org/bugzilla3/show_bug.cgi?id=25516 Bug ID: 25516 Summary: Item/pickup_locations wantarray removed, so dies on Perl >=5.24 where "autoderef" feature absent Change sponsored?: --- Product: Koha Version: master Hardware: All OS: All Status: NEW Severity: normal Priority: P5 - low Component: Hold requests Assignee: stalkernoid@gmail.com Reporter: nugged@gmail.com QA Contact: testopia@bugs.koha-community.org CC: gmcharlt@gmail.com, slavashishkin@gmail.com After last updates, until around May 11, "wantarray" in sub pickup_locations was removed, but it might be hidden on Perls before v5.24, because there was autoderef experimental feature (https://www.effectiveperlprogramming.com/2010/11/use-array-references-with-t...), the feature removed in Perl v5.24, and Ubuntu 16.04 has Perl v5.22, Ubuntu 18.04 has Perl v5.26. Since newer Perls it will definitely produce the error because now it uses $arr_reference as a single item and maps over it once, and the process dies with "no method" or whatever. There might be other places in the code that uses this v5.14-5.24 feature for example to keys, map, grep $arr_reference. The place I bumped in: 1. On the clean devenv after “reset_all” go to /cgi-bin/koha/admin/smart-rules.pl and press “Save” button on “Default checkout, hold and return policy” to save the empty record (GUI allows that), – this is needed to have in the table “circulation_rule” key “hold_fulfillment_policy” appeared with empty string value so code will reach the right place. Another option to have the same “hold_fulfillment_policy” empty string is to reset DB and go through onboarding.pl (and how I found). So, after onboarding, you don’t ever need to save the empty record, it will be filled automatically. To check: SELECT rule_name, rule_value FROM circulation_rules WHERE rule_name='hold_fulfillment_policy' it produces: "hold_fulfillment_policy", "" 2. open item record /cgi-bin/koha/reserve/request.pl?biblionumber=1&borrowernumber=1 - it produced the bug: Software error: Can't call method "unblessed" on unblessed reference at ../reserve/request.pl line 581. The code from request.pl line 581: ``` $item->{pickup_locations} = join( ', ', map { $_->unblessed->{branchname} } Koha::Items->find($itemnumber) ->pickup_locations( { patron => $patron } ) ); $item->{pickup_locations_code} = join( ',', map { $_->unblessed->{branchcode} } Koha::Items->find($itemnumber) ->pickup_locations( { patron => $patron } ) ); ``` and that's because sub pickup_locations (recent changes, where wantarray removed, so might be more places) now does this: return \@pickup_locations; Yet it might work on Perl <5.24. Peter: please search through code where we might have similar issues, and meanwhile, provide a patch for the current one above. -- You are receiving this mail because: You are watching all bug changes.
https://bugs.koha-community.org/bugzilla3/show_bug.cgi?id=25516 Jonathan Druart <jonathan.druart@bugs.koha-community.org> changed: What |Removed |Added ---------------------------------------------------------------------------- CC| |jonathan.druart@bugs.koha-c | |ommunity.org Depends on| |24368 Referenced Bugs: https://bugs.koha-community.org/bugzilla3/show_bug.cgi?id=24368 [Bug 24368] Koha::Libraries->pickup_locations needs refactoring/ratifying -- You are receiving this mail because: You are watching all bug changes.
https://bugs.koha-community.org/bugzilla3/show_bug.cgi?id=25516 --- Comment #1 from Jonathan Druart <jonathan.druart@bugs.koha-community.org> --- Are you planning on submitting a patch soon? I'd like 2. to be part of 20.05. -- You are receiving this mail because: You are watching all bug changes.
https://bugs.koha-community.org/bugzilla3/show_bug.cgi?id=25516 --- Comment #2 from Peter Vashchuk <stalkernoid@gmail.com> --- Created attachment 105012 --> https://bugs.koha-community.org/bugzilla3/attachment.cgi?id=105012&action=edit Bug 25516: Fix for "Can't call method unblessed on unblessed reference" Software error: Can't call method "unblessed" on unblessed reference at ../reserve/request.pl line 581. was caused by recent commit with `wantarray` removal in sub pickup_locations in ‘Item.pm’ and visible on fresher Perls (where experimental feature "autoderef" removed https://www.effectiveperlprogramming.com/2010/11/use-array-references-with-t... ) To test: 1) Get a clean dev environment after "reset_all" 2) Add an empty record for “Default checkout, hold and return policy” on /cgi-bin/koha/admin/smart-rules.pl. 3) Open item record, like /cgi-bin/koha/reserve/request.pl?biblionumber=1&borrowernumber=1 4) Observe the error (Can't call method "unblessed" on unblessed reference at ../reserve/request.pl line 581.) 5) Apply patch. 6) Repeat steps 2 and 3. 7) Observe that the error is gone. -- You are receiving this mail because: You are watching all bug changes.
https://bugs.koha-community.org/bugzilla3/show_bug.cgi?id=25516 Peter Vashchuk <stalkernoid@gmail.com> changed: What |Removed |Added ---------------------------------------------------------------------------- Status|NEW |Needs Signoff -- You are receiving this mail because: You are watching all bug changes.
https://bugs.koha-community.org/bugzilla3/show_bug.cgi?id=25516 Jonathan Druart <jonathan.druart@bugs.koha-community.org> changed: What |Removed |Added ---------------------------------------------------------------------------- Severity|normal |critical Keywords| |rel_20_05_candidate -- You are receiving this mail because: You are watching all bug changes.
https://bugs.koha-community.org/bugzilla3/show_bug.cgi?id=25516 Jonathan Druart <jonathan.druart@bugs.koha-community.org> changed: What |Removed |Added ---------------------------------------------------------------------------- QA Contact|testopia@bugs.koha-communit |jonathan.druart@bugs.koha-c |y.org |ommunity.org -- You are receiving this mail because: You are watching all bug changes.
https://bugs.koha-community.org/bugzilla3/show_bug.cgi?id=25516 Victor Grousset/tuxayo <victor@tuxayo.net> changed: What |Removed |Added ---------------------------------------------------------------------------- Attachment #105012|0 |1 is obsolete| | --- Comment #3 from Victor Grousset/tuxayo <victor@tuxayo.net> --- Created attachment 105040 --> https://bugs.koha-community.org/bugzilla3/attachment.cgi?id=105040&action=edit Bug 25516: Fix for "Can't call method unblessed on unblessed reference" Software error: Can't call method "unblessed" on unblessed reference at ../reserve/request.pl line 581. was caused by recent commit with `wantarray` removal in sub pickup_locations in ‘Item.pm’ and visible on fresher Perls (where experimental feature "autoderef" removed https://www.effectiveperlprogramming.com/2010/11/use-array-references-with-t... ) To test: 1) Get a clean dev environment after "reset_all" 2) Add an empty record for “Default checkout, hold and return policy” on /cgi-bin/koha/admin/smart-rules.pl. 3) Open item record, like /cgi-bin/koha/reserve/request.pl?biblionumber=1&borrowernumber=1 4) Observe the error (Can't call method "unblessed" on unblessed reference at ../reserve/request.pl line 581.) 5) Apply patch. 6) Repeat steps 2 and 3. 7) Observe that the error is gone. Signed-off-by: Victor Grousset/tuxayo <victor@tuxayo.net> -- You are receiving this mail because: You are watching all bug changes.
https://bugs.koha-community.org/bugzilla3/show_bug.cgi?id=25516 Victor Grousset/tuxayo <victor@tuxayo.net> changed: What |Removed |Added ---------------------------------------------------------------------------- Status|Needs Signoff |Signed Off CC| |victor@tuxayo.net --- Comment #4 from Victor Grousset/tuxayo <victor@tuxayo.net> --- It works ! :D -- You are receiving this mail because: You are watching all bug changes.
https://bugs.koha-community.org/bugzilla3/show_bug.cgi?id=25516 Jonathan Druart <jonathan.druart@bugs.koha-community.org> changed: What |Removed |Added ---------------------------------------------------------------------------- Status|Signed Off |Passed QA -- You are receiving this mail because: You are watching all bug changes.
https://bugs.koha-community.org/bugzilla3/show_bug.cgi?id=25516 Jonathan Druart <jonathan.druart@bugs.koha-community.org> changed: What |Removed |Added ---------------------------------------------------------------------------- Attachment #105040|0 |1 is obsolete| | --- Comment #5 from Jonathan Druart <jonathan.druart@bugs.koha-community.org> --- Created attachment 105058 --> https://bugs.koha-community.org/bugzilla3/attachment.cgi?id=105058&action=edit Bug 25516: Fix for "Can't call method unblessed on unblessed reference" Software error: Can't call method "unblessed" on unblessed reference at ../reserve/request.pl line 581. was caused by recent commit with `wantarray` removal in sub pickup_locations in ‘Item.pm’ and visible on fresher Perls (where experimental feature "autoderef" removed https://www.effectiveperlprogramming.com/2010/11/use-array-references-with-t... ) To test: 1) Get a clean dev environment after "reset_all" 2) Add an empty record for “Default checkout, hold and return policy” on /cgi-bin/koha/admin/smart-rules.pl. 3) Open item record, like /cgi-bin/koha/reserve/request.pl?biblionumber=1&borrowernumber=1 4) Observe the error (Can't call method "unblessed" on unblessed reference at ../reserve/request.pl line 581.) 5) Apply patch. 6) Repeat steps 2 and 3. 7) Observe that the error is gone. Signed-off-by: Victor Grousset/tuxayo <victor@tuxayo.net> Signed-off-by: Jonathan Druart <jonathan.druart@bugs.koha-community.org> Amended-patch: replace tab indentation with spaces -- You are receiving this mail because: You are watching all bug changes.
https://bugs.koha-community.org/bugzilla3/show_bug.cgi?id=25516 --- Comment #6 from Jonathan Druart <jonathan.druart@bugs.koha-community.org> --- Peter, thanks for the patch! Make sure you configure your editor correctly for this project, we use 4 spaces indentation, no tab ;) I amended the patch. -- You are receiving this mail because: You are watching all bug changes.
https://bugs.koha-community.org/bugzilla3/show_bug.cgi?id=25516 Martin Renvoize <martin.renvoize@ptfs-europe.com> changed: What |Removed |Added ---------------------------------------------------------------------------- Version(s)| |20.05.00 released in| | Status|Passed QA |Pushed to master -- You are receiving this mail because: You are watching all bug changes.
https://bugs.koha-community.org/bugzilla3/show_bug.cgi?id=25516 --- Comment #7 from Martin Renvoize <martin.renvoize@ptfs-europe.com> --- Nice work everyone! Pushed to master for 20.05 -- You are receiving this mail because: You are watching all bug changes.
https://bugs.koha-community.org/bugzilla3/show_bug.cgi?id=25516 Martin Renvoize <martin.renvoize@ptfs-europe.com> changed: What |Removed |Added ---------------------------------------------------------------------------- CC| |martin.renvoize@ptfs-europe | |.com Keywords|rel_20_05_candidate | -- You are receiving this mail because: You are watching all bug changes.
https://bugs.koha-community.org/bugzilla3/show_bug.cgi?id=25516 --- Comment #8 from Andrew Nugged <nugged@gmail.com> --- (In reply to Jonathan Druart from comment #6)
Make sure you configure your editor correctly for this project, we use 4 spaces indentation, no tab ;)
actually, git's config for 'whitespace' we all have: 'trailing-space,space-before-tab' to protect ourselves against occasional things like above, but it protects in space+tab, in another order, not tab+space, maybe we should try 'indent-with-non-tab,tab-in-indent' too... But now we even added this in our REGEX in team's pre-commit hook now :P -- You are receiving this mail because: You are watching all bug changes.
https://bugs.koha-community.org/bugzilla3/show_bug.cgi?id=25516 Joy Nelson <joy@bywatersolutions.com> changed: What |Removed |Added ---------------------------------------------------------------------------- CC| |joy@bywatersolutions.com --- Comment #9 from Joy Nelson <joy@bywatersolutions.com> --- missing dependency - not backported to 19.11.x -- You are receiving this mail because: You are watching all bug changes.
participants (1)
-
bugzilla-daemon@bugs.koha-community.org