Summary: | Forbid Koha::Objects->find calls in list context | ||
---|---|---|---|
Product: | Koha | Reporter: | Jonathan Druart <jonathan.druart> |
Component: | Architecture, internals, and plumbing | Assignee: | Jonathan Druart <jonathan.druart> |
Status: | CLOSED FIXED | QA Contact: | Testopia <testopia> |
Severity: | enhancement | ||
Priority: | P5 - low | CC: | fridolin.somers, kyle |
Version: | unspecified | ||
Hardware: | All | ||
OS: | All | ||
Change sponsored?: | --- | Patch complexity: | --- |
Documentation contact: | Documentation submission: | ||
Text to go in the release notes: | Version(s) released in: | ||
Circulation function: | |||
Bug Depends on: | 18179 | ||
Bug Blocks: | 18361, 19695, 19809 | ||
Attachments: |
Bug 18539: Forbid list context calls for Koha::Objects->find
Bug 18539: Forbid list context calls for Koha::Objects->find Bug 18539: remove occurrence in ReNewSubscription.t Bug 18539: remove occurrence in ReNewSubscription.t |
Description
Jonathan Druart
2017-05-04 14:08:39 UTC
Created attachment 63110 [details] [review] Bug 18539: Forbid list context calls for Koha::Objects->find Reading https://perlmaven.com/how-to-return-undef-from-a-function this sound like the more correct behaviour. Considering: $template->param( stuff => Koha::Stuffs->find( $id ), foo => 1, ); without this patch, if the $id does not represent any rows in the DB, stuff will be assigned to 'foo' and $foo will be undef in the template. That can lead to very bad side-effects. With this patch we make sure that it will never happen again. Test plan: prove t/db_dependent/Koha/Objects.t should return green Signed-off-by: Marc Véron <veron@veron.ch> Signed-off-by: Nick Clemens <nick@bywatersolutions.com> Created attachment 64338 [details] [review] Bug 18539: Forbid list context calls for Koha::Objects->find Reading https://perlmaven.com/how-to-return-undef-from-a-function this sound like the more correct behaviour. Considering: $template->param( stuff => Koha::Stuffs->find( $id ), foo => 1, ); without this patch, if the $id does not represent any rows in the DB, stuff will be assigned to 'foo' and $foo will be undef in the template. That can lead to very bad side-effects. With this patch we make sure that it will never happen again. Test plan: prove t/db_dependent/Koha/Objects.t should return green Signed-off-by: Marc Véron <veron@veron.ch> Signed-off-by: Nick Clemens <nick@bywatersolutions.com> Signed-off-by: Kyle M Hall <kyle@bywatersolutions.com> Created attachment 64351 [details] [review] Bug 18539: remove occurrence in ReNewSubscription.t Pushed to master for 17.11, thanks to everybody involved! Enhancement not pushed to 17.05.x Actual patch Bug 18539: remove occurrence in ReNewSubscription.t contains the remove of t/db_dependent/00-strict.t. But I see this was not pushed into master : http://git.koha-community.org/gitweb/?p=koha.git;a=commit;h=ad7ff09b995e5275f2c6d664b31351321b1674af I finally to push to 17.05.x to be able to push Bug 18361. Will be in 17.05.03. Created attachment 65458 [details] [review] Bug 18539: remove occurrence in ReNewSubscription.t Signed-off-by: Jonathan Druart <jonathan.druart@bugs.koha-community.org> These patches have been pushed to 16.11.x and will be in 16.11.11. |