]> git.koha-community.org Git - koha.git/commit
Bug 18539: Forbid list context calls for Koha::Objects->find
authorJonathan Druart <jonathan.druart@bugs.koha-community.org>
Tue, 18 Apr 2017 16:49:18 +0000 (13:49 -0300)
committerFridolin Somers <fridolin.somers@biblibre.com>
Thu, 3 Aug 2017 07:35:36 +0000 (09:35 +0200)
commit5a2604144f114d242d7e4860603fd4811937f44c
tree779483e4a13894b07da1093f4d091c5b85640d2a
parent1da77ea584bcc2a2878106b6bc174b21bb0837ff
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>
Signed-off-by: Jonathan Druart <jonathan.druart@bugs.koha-community.org>
(cherry picked from commit 15cbf14f4d4f8039ad7820ce37da202b19e0075d)
Signed-off-by: Fridolin Somers <fridolin.somers@biblibre.com>
Koha/Objects.pm
t/db_dependent/Koha/Objects.t