From 07cd6560b5d8334b11ac8c998c1d1156d01a4bcb Mon Sep 17 00:00:00 2001 From: Jonathan Druart Date: Fri, 14 Dec 2018 16:15:24 -0300 Subject: [PATCH] Bug 22006: Handle undefined itemnumber for Koha::Account::Line->item If there is no item linked to an account line, the ->item method should return undef. Without this patch it explodes with: Carp::croak('DBIC result _type isn\'t of the _type Item') called at /home/vagrant/kohaclone/Koha/Object.pm line 102 Exists since the introduction of this method by bug 12001 Reported on bug 19489 comment 18. Test plan: prove t/db_dependent/Koha/Account/Lines.t must return green Signed-off-by: Pierre-Marc Thibault Signed-off-by: Tomas Cohen Arazi Signed-off-by: Nick Clemens (cherry picked from commit 6c8089b40fef1b59ab056bae8817933afdb2fcc3) Signed-off-by: Martin Renvoize --- Koha/Account/Line.pm | 1 + 1 file changed, 1 insertion(+) diff --git a/Koha/Account/Line.pm b/Koha/Account/Line.pm index 3573e604e6..9a538476f9 100644 --- a/Koha/Account/Line.pm +++ b/Koha/Account/Line.pm @@ -48,6 +48,7 @@ Return the item linked to this account line if exists sub item { my ( $self ) = @_; my $rs = $self->_result->itemnumber; + return unless $rs; return Koha::Item->_new_from_dbic( $rs ); } -- 2.39.5