From fcc6836925e6903cf5c1e27a63551820bd5b9569 Mon Sep 17 00:00:00 2001 From: Jonathan Druart Date: Fri, 8 May 2020 15:17:31 +0200 Subject: [PATCH] Bug 25423: Force call to update and empty with an instanciated object Signed-off-by: Tomas Cohen Arazi Signed-off-by: Jonathan Druart --- Koha/Objects.pm | 13 ++++++++++--- 1 file changed, 10 insertions(+), 3 deletions(-) diff --git a/Koha/Objects.pm b/Koha/Objects.pm index 2bf33917a7..7824d83d27 100644 --- a/Koha/Objects.pm +++ b/Koha/Objects.pm @@ -24,6 +24,7 @@ use List::MoreUtils qw( none ); use Class::Inspector; use Koha::Database; +use Koha::Exceptions::Object; =head1 NAME @@ -225,6 +226,11 @@ catch wrong uses as well. sub update { my ($self, $fields, $options) = @_; + Koha::Exceptions::Object::NotInstantiated->throw( + method => 'update', + class => $self + ) unless ref $self; + my $no_triggers = $options->{no_triggers}; if ( @@ -325,9 +331,10 @@ an iterator). sub empty { my ($self) = @_; - unless (ref($self)) { - $self = $self->new; - } + Koha::Exceptions::Object::NotInstantiated->throw( + method => 'empty', + class => $self + ) unless ref $self; $self->_resultset()->set_cache([]); -- 2.39.5