[Koha-bugs] [Bug 18539] Forbid Koha::Objects->find calls in list context
bugzilla-daemon at bugs.koha-community.org
bugzilla-daemon at bugs.koha-community.org
Thu May 4 16:11:20 CEST 2017
https://bugs.koha-community.org/bugzilla3/show_bug.cgi?id=18539
--- Comment #1 from Jonathan Druart <jonathan.druart at bugs.koha-community.org> ---
Created attachment 63110
-->
https://bugs.koha-community.org/bugzilla3/attachment.cgi?id=63110&action=edit
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 at veron.ch>
Signed-off-by: Nick Clemens <nick at bywatersolutions.com>
--
You are receiving this mail because:
You are watching all bug changes.
More information about the Koha-bugs
mailing list