[Bug 29806] New: ->pickup_locations should always be called in scalar context
https://bugs.koha-community.org/bugzilla3/show_bug.cgi?id=29806 Bug ID: 29806 Summary: ->pickup_locations should always be called in scalar context Change sponsored?: --- Product: Koha Version: master Hardware: All OS: All Status: NEW Severity: normal Priority: P5 - low Component: Architecture, internals, and plumbing Assignee: koha-bugs@lists.koha-community.org Reporter: tomascohen@gmail.com QA Contact: testopia@bugs.koha-community.org The Koha::{Biblio|Item}->pickup_locations methods internally use Koha::Libraries->empty, which doesn't honour list context (bug 28871). When called in list context, if the Koha::Libraries resultset was built using ->empty, then things will explode, as exposed by bug 29804. -- 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=29806 Tomás Cohen Arazi <tomascohen@gmail.com> changed: What |Removed |Added ---------------------------------------------------------------------------- See Also| |https://bugs.koha-community | |.org/bugzilla3/show_bug.cgi | |?id=28871 Depends on| |29804 Status|NEW |ASSIGNED Assignee|koha-bugs@lists.koha-commun |tomascohen@gmail.com |ity.org | Referenced Bugs: https://bugs.koha-community.org/bugzilla3/show_bug.cgi?id=29804 [Bug 29804] Koha::Hold->is_pickup_location_valid explodes if empty list of pickup locations -- 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=29806 --- Comment #1 from Tomás Cohen Arazi <tomascohen@gmail.com> --- I did a: $ git grep '\->pickup_locations' and my (manual) findings are: Koha/Biblio.pm: ok Koha/Biblios.pm: ok Koha/Item.pm: ok Koha/REST/V1/Biblios.pm: ok Koha/REST/V1/Holds.pm: boo Koha/Template/Plugin/Branches.pm: boo reserve/request.pl: boo t/db_dependent/Koha/Biblio.t: ok t/db_dependent/Koha/Biblios.t: ok t/db_dependent/Koha/Hold.t: ok t/db_dependent/Koha/Item.t: ok t/db_dependent/Template/Plugin/Branches.t: ok t/db_dependent/api/v1/holds.t: ok Working on fixes... -- You are receiving this mail because: You are watching all bug changes.
https://bugs.koha-community.org/bugzilla3/show_bug.cgi?id=29806 Tomás Cohen Arazi <tomascohen@gmail.com> changed: What |Removed |Added ---------------------------------------------------------------------------- Depends on| |29807 Referenced Bugs: https://bugs.koha-community.org/bugzilla3/show_bug.cgi?id=29807 [Bug 29807] Branches template doesn't handle empty lists correctly -- You are receiving this mail because: You are watching all bug changes.
https://bugs.koha-community.org/bugzilla3/show_bug.cgi?id=29806 --- Comment #2 from Tomás Cohen Arazi <tomascohen@gmail.com> --- Koha/Template/Plugin/Branches.pm solved on bug 29807. -- You are receiving this mail because: You are watching all bug changes.
https://bugs.koha-community.org/bugzilla3/show_bug.cgi?id=29806 Tomás Cohen Arazi <tomascohen@gmail.com> changed: What |Removed |Added ---------------------------------------------------------------------------- Status|ASSIGNED |Needs Signoff CC| |tomascohen@gmail.com Patch complexity|--- |Small patch -- You are receiving this mail because: You are watching all bug changes.
https://bugs.koha-community.org/bugzilla3/show_bug.cgi?id=29806 --- Comment #3 from Tomás Cohen Arazi <tomascohen@gmail.com> --- Created attachment 129058 --> https://bugs.koha-community.org/bugzilla3/attachment.cgi?id=129058&action=edit Bug 29806: Call ->as_list for ->pickup_locations on request.pl -- You are receiving this mail because: You are watching all bug changes.
https://bugs.koha-community.org/bugzilla3/show_bug.cgi?id=29806 --- Comment #4 from Tomás Cohen Arazi <tomascohen@gmail.com> --- Created attachment 129059 --> https://bugs.koha-community.org/bugzilla3/attachment.cgi?id=129059&action=edit Bug 29806: Regression tests -- You are receiving this mail because: You are watching all bug changes.
https://bugs.koha-community.org/bugzilla3/show_bug.cgi?id=29806 --- Comment #5 from Tomás Cohen Arazi <tomascohen@gmail.com> --- Created attachment 129060 --> https://bugs.koha-community.org/bugzilla3/attachment.cgi?id=129060&action=edit Bug 29806: Fix POST /holds use of pickup_locations This patch makes Koha::Item->pickup_locations and Koha::Biblio->pickup_locations explicitly call ->as_list in list context. This way we workaround bug 28871. To test: 1. Apply the regression tests patch 2. Run: $ kshell k$ prove t/db_dependent/api/v1/holds.t => FAIL: Tests fail, the route gives a 500 (unhandled exception) 3. Apply this patch 4. Repeat 2 => SUCCESS: Tests pass, the route correctly returns a 400 with a message about the pickup location being invalid 5. Sign off :-D -- You are receiving this mail because: You are watching all bug changes.
https://bugs.koha-community.org/bugzilla3/show_bug.cgi?id=29806 Tomás Cohen Arazi <tomascohen@gmail.com> changed: What |Removed |Added ---------------------------------------------------------------------------- CC| |jonathan.druart+koha@gmail. | |com, | |katrin.fischer@bsz-bw.de, | |kyle@bywatersolutions.com, | |martin.renvoize@ptfs-europe | |.com -- You are receiving this mail because: You are watching all bug changes.
https://bugs.koha-community.org/bugzilla3/show_bug.cgi?id=29806 Tomás Cohen Arazi <tomascohen@gmail.com> changed: What |Removed |Added ---------------------------------------------------------------------------- Text to go in the| |The release notes| |Koha::Biblio->pickup_locati | |ons and | |Koha::Item->pickup_location | |methods don't always honour | |list context. Because of | |this, when used, they | |should assume scalar | |context. If list context | |was required, the developer | |needs to explicitly chain a | |->as_list call. | | | |This patch | |tracks the uses of this | |methods and adjusts | |accordingly. -- You are receiving this mail because: You are watching all bug changes.
https://bugs.koha-community.org/bugzilla3/show_bug.cgi?id=29806 David Nind <david@davidnind.com> changed: What |Removed |Added ---------------------------------------------------------------------------- Status|Needs Signoff |Signed Off -- You are receiving this mail because: You are watching all bug changes.
https://bugs.koha-community.org/bugzilla3/show_bug.cgi?id=29806 David Nind <david@davidnind.com> changed: What |Removed |Added ---------------------------------------------------------------------------- Attachment #129059|0 |1 is obsolete| | --- Comment #6 from David Nind <david@davidnind.com> --- Created attachment 129130 --> https://bugs.koha-community.org/bugzilla3/attachment.cgi?id=129130&action=edit Bug 29806: Regression tests Signed-off-by: David Nind <david@davidnind.com> -- You are receiving this mail because: You are watching all bug changes.
https://bugs.koha-community.org/bugzilla3/show_bug.cgi?id=29806 David Nind <david@davidnind.com> changed: What |Removed |Added ---------------------------------------------------------------------------- Attachment #129058|0 |1 is obsolete| | --- Comment #7 from David Nind <david@davidnind.com> --- Created attachment 129131 --> https://bugs.koha-community.org/bugzilla3/attachment.cgi?id=129131&action=edit Bug 29806: Call ->as_list for ->pickup_locations on request.pl Signed-off-by: David Nind <david@davidnind.com> -- You are receiving this mail because: You are watching all bug changes.
https://bugs.koha-community.org/bugzilla3/show_bug.cgi?id=29806 David Nind <david@davidnind.com> changed: What |Removed |Added ---------------------------------------------------------------------------- Attachment #129060|0 |1 is obsolete| | --- Comment #8 from David Nind <david@davidnind.com> --- Created attachment 129132 --> https://bugs.koha-community.org/bugzilla3/attachment.cgi?id=129132&action=edit Bug 29806: Fix POST /holds use of pickup_locations This patch makes Koha::Item->pickup_locations and Koha::Biblio->pickup_locations explicitly call ->as_list in list context. This way we workaround bug 28871. To test: 1. Apply the regression tests patch 2. Run: $ kshell k$ prove t/db_dependent/api/v1/holds.t => FAIL: Tests fail, the route gives a 500 (unhandled exception) 3. Apply this patch 4. Repeat 2 => SUCCESS: Tests pass, the route correctly returns a 400 with a message about the pickup location being invalid 5. Sign off :-D Signed-off-by: David Nind <david@davidnind.com> -- You are receiving this mail because: You are watching all bug changes.
https://bugs.koha-community.org/bugzilla3/show_bug.cgi?id=29806 Jonathan Druart <jonathan.druart+koha@gmail.com> 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=29806 Jonathan Druart <jonathan.druart+koha@gmail.com> changed: What |Removed |Added ---------------------------------------------------------------------------- Attachment #129130|0 |1 is obsolete| | --- Comment #9 from Jonathan Druart <jonathan.druart+koha@gmail.com> --- Created attachment 129183 --> https://bugs.koha-community.org/bugzilla3/attachment.cgi?id=129183&action=edit Bug 29806: Regression tests Signed-off-by: David Nind <david@davidnind.com> Signed-off-by: Jonathan Druart <jonathan.druart@bugs.koha-community.org> -- You are receiving this mail because: You are watching all bug changes.
https://bugs.koha-community.org/bugzilla3/show_bug.cgi?id=29806 Jonathan Druart <jonathan.druart+koha@gmail.com> changed: What |Removed |Added ---------------------------------------------------------------------------- Attachment #129131|0 |1 is obsolete| | --- Comment #10 from Jonathan Druart <jonathan.druart+koha@gmail.com> --- Created attachment 129184 --> https://bugs.koha-community.org/bugzilla3/attachment.cgi?id=129184&action=edit Bug 29806: Call ->as_list for ->pickup_locations on request.pl Signed-off-by: David Nind <david@davidnind.com> Signed-off-by: Jonathan Druart <jonathan.druart@bugs.koha-community.org> -- You are receiving this mail because: You are watching all bug changes.
https://bugs.koha-community.org/bugzilla3/show_bug.cgi?id=29806 Jonathan Druart <jonathan.druart+koha@gmail.com> changed: What |Removed |Added ---------------------------------------------------------------------------- Attachment #129132|0 |1 is obsolete| | --- Comment #11 from Jonathan Druart <jonathan.druart+koha@gmail.com> --- Created attachment 129185 --> https://bugs.koha-community.org/bugzilla3/attachment.cgi?id=129185&action=edit Bug 29806: Fix POST /holds use of pickup_locations This patch makes Koha::Item->pickup_locations and Koha::Biblio->pickup_locations explicitly call ->as_list in list context. This way we workaround bug 28871. To test: 1. Apply the regression tests patch 2. Run: $ kshell k$ prove t/db_dependent/api/v1/holds.t => FAIL: Tests fail, the route gives a 500 (unhandled exception) 3. Apply this patch 4. Repeat 2 => SUCCESS: Tests pass, the route correctly returns a 400 with a message about the pickup location being invalid 5. Sign off :-D Signed-off-by: David Nind <david@davidnind.com> Signed-off-by: Jonathan Druart <jonathan.druart@bugs.koha-community.org> -- You are receiving this mail because: You are watching all bug changes.
https://bugs.koha-community.org/bugzilla3/show_bug.cgi?id=29806 --- Comment #12 from Jonathan Druart <jonathan.druart+koha@gmail.com> --- Created attachment 129186 --> https://bugs.koha-community.org/bugzilla3/attachment.cgi?id=129186&action=edit Bug 29806: (follow-up) Call ->as_list for ->pickup_locations on request.pl Signed-off-by: Jonathan Druart <jonathan.druart@bugs.koha-community.org> -- You are receiving this mail because: You are watching all bug changes.
https://bugs.koha-community.org/bugzilla3/show_bug.cgi?id=29806 --- Comment #13 from Tomás Cohen Arazi <tomascohen@gmail.com> --- Hi! Thanks for the follow-up. Strictly speaking, Koha::Biblios->pickup_locations IS list context aware so this wouldn't be needed. I skipped it because of that reason, but that was before I wrote to koha-devel with my suggestion that we call ->as_list explicitly all the time. So, this patch is welcome and good to be included! (In reply to Jonathan Druart from comment #12)
Created attachment 129186 [details] [review] Bug 29806: (follow-up) Call ->as_list for ->pickup_locations on request.pl
Signed-off-by: Jonathan Druart <jonathan.druart@bugs.koha-community.org>
-- You are receiving this mail because: You are watching all bug changes.
https://bugs.koha-community.org/bugzilla3/show_bug.cgi?id=29806 Tomás Cohen Arazi <tomascohen@gmail.com> changed: What |Removed |Added ---------------------------------------------------------------------------- QA Contact|testopia@bugs.koha-communit |jonathan.druart+koha@gmail. |y.org |com -- You are receiving this mail because: You are watching all bug changes.
https://bugs.koha-community.org/bugzilla3/show_bug.cgi?id=29806 Tomás Cohen Arazi <tomascohen@gmail.com> changed: What |Removed |Added ---------------------------------------------------------------------------- Blocks| |29844 Referenced Bugs: https://bugs.koha-community.org/bugzilla3/show_bug.cgi?id=29844 [Bug 29844] Remove uses of wantarray in Koha::Objects -- You are receiving this mail because: You are watching all bug changes.
https://bugs.koha-community.org/bugzilla3/show_bug.cgi?id=29806 Fridolin Somers <fridolin.somers@biblibre.com> changed: What |Removed |Added ---------------------------------------------------------------------------- Version(s)| |22.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=29806 --- Comment #14 from Fridolin Somers <fridolin.somers@biblibre.com> --- Pushed to master for 22.05, thanks to everybody involved 🦄 -- You are receiving this mail because: You are watching all bug changes.
https://bugs.koha-community.org/bugzilla3/show_bug.cgi?id=29806 Kyle M Hall <kyle@bywatersolutions.com> changed: What |Removed |Added ---------------------------------------------------------------------------- Version(s)|22.05.00 |22.05.00,21.11.03 released in| | Status|Pushed to master |Pushed to stable --- Comment #15 from Kyle M Hall <kyle@bywatersolutions.com> --- Pushed to 21.11.x for 21.11.03 -- You are receiving this mail because: You are watching all bug changes.
https://bugs.koha-community.org/bugzilla3/show_bug.cgi?id=29806 Andrew Fuerste-Henry <andrew@bywatersolutions.com> changed: What |Removed |Added ---------------------------------------------------------------------------- Version(s)|22.05.00,21.11.03 |22.05.00,21.11.03,21.05.11 released in| | Status|Pushed to stable |Pushed to oldstable CC| |andrew@bywatersolutions.com --- Comment #16 from Andrew Fuerste-Henry <andrew@bywatersolutions.com> --- Pushed to 21.05.x for 21.05.11 -- You are receiving this mail because: You are watching all bug changes.
https://bugs.koha-community.org/bugzilla3/show_bug.cgi?id=29806 Bug 29806 depends on bug 29804, which changed state. Bug 29804 Summary: Koha::Hold->is_pickup_location_valid explodes if empty list of pickup locations https://bugs.koha-community.org/bugzilla3/show_bug.cgi?id=29804 What |Removed |Added ---------------------------------------------------------------------------- Status|Pushed to oldstable |RESOLVED Resolution|--- |FIXED -- You are receiving this mail because: You are watching all bug changes.
https://bugs.koha-community.org/bugzilla3/show_bug.cgi?id=29806 Bug 29806 depends on bug 29807, which changed state. Bug 29807 Summary: Branches template plugin doesn't handle empty lists correctly https://bugs.koha-community.org/bugzilla3/show_bug.cgi?id=29807 What |Removed |Added ---------------------------------------------------------------------------- Status|Pushed to oldstable |RESOLVED Resolution|--- |FIXED -- You are receiving this mail because: You are watching all bug changes.
https://bugs.koha-community.org/bugzilla3/show_bug.cgi?id=29806 Victor Grousset/tuxayo <victor@tuxayo.net> changed: What |Removed |Added ---------------------------------------------------------------------------- CC| |victor@tuxayo.net Resolution|--- |FIXED Status|Pushed to oldstable |RESOLVED --- Comment #17 from Victor Grousset/tuxayo <victor@tuxayo.net> --- Not backported to oldoldstable (20.11.x). Feel free to ask if it's needed. -- You are receiving this mail because: You are watching all bug changes.
participants (1)
-
bugzilla-daemon@bugs.koha-community.org