]> 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)
committerKatrin Fischer <katrin.fischer.83@web.de>
Sat, 5 Aug 2017 12:43:58 +0000 (14:43 +0200)
commitc5b576135a3a29ab482445afaaecadf12566db3c
tree90b7fe669f4702e68ce8fa8651e18bddbad9dfcc
parent9793ba80e7879d06d0231c787b12fd3d1f9c8ef5
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>
(cherry picked from commit 5a2604144f114d242d7e4860603fd4811937f44c)
Signed-off-by: Katrin Fischer <katrin.fischer.83@web.de>
Koha/Objects.pm
t/db_dependent/Koha/Objects.t