From 2165e536efd5710f14bd1230cd3ebe04ef0e3447 Mon Sep 17 00:00:00 2001 From: Martin Renvoize Date: Tue, 26 Oct 2021 11:24:25 +0100 Subject: [PATCH] Bug 28700: Throw exception on dirty columns for unblessed This patch updates the unblessed method to throw an exception when called with dirty columns. --- Koha/Exceptions/Object.pm | 5 +++++ Koha/Object.pm | 4 ++++ 2 files changed, 9 insertions(+) diff --git a/Koha/Exceptions/Object.pm b/Koha/Exceptions/Object.pm index 688a97cd5a..684c5eb4c7 100644 --- a/Koha/Exceptions/Object.pm +++ b/Koha/Exceptions/Object.pm @@ -23,6 +23,11 @@ use Exception::Class ( 'Koha::Exceptions::Object' => { isa => 'Koha::Exceptions::Exception', }, + 'Koha::Exceptions::Object::Dirty' => { + isa => 'Koha::Exceptions::Object', + description => "Dirty object passed to unblessed", + fields => ['dirty_fields'] + }, 'Koha::Exceptions::Object::DuplicateID' => { isa => 'Koha::Exceptions::Object', description => "Duplicate ID passed", diff --git a/Koha/Object.pm b/Koha/Object.pm index 8daffd536f..03576a810f 100644 --- a/Koha/Object.pm +++ b/Koha/Object.pm @@ -319,6 +319,10 @@ Returns an unblessed representation of object. sub unblessed { my ($self) = @_; + Koha::Exceptions::Object::Dirty->throw( + { dirty_fields => [ keys %{ $self->_result->get_dirty_columns } ] } ) + if $self->_result->get_dirty_columns; + return { $self->_result->get_columns }; } -- 2.20.1