From eb36400a9b165f2b3c8710cd3e3b4b74cb63e782 Mon Sep 17 00:00:00 2001 From: Martin Renvoize Date: Thu, 26 Mar 2026 09:19:07 +0100 Subject: [PATCH] Bug 40136: (follow-up) Stringify DateTime objects in _unblessed_for_log Koha::Object::AUTOLOAD calls set_column directly, bypassing DBIC's inflate/deflate mechanism. This means date/datetime column values set via Koha object accessors (without store()) can end up as raw DateTime objects in _column_data. When _unblessed_for_log then calls get_column, it retrieves the DateTime object, which encode_json in C4::Log cannot serialise, causing the patron delete (and test) to die with an "encountered object" error. Fix by stringifying any DateTime objects found in the column data before returning from _unblessed_for_log. Signed-off-by: Martin Renvoize --- Koha/Patron.pm | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/Koha/Patron.pm b/Koha/Patron.pm index cc8a3615ae..2ce493454d 100644 --- a/Koha/Patron.pm +++ b/Koha/Patron.pm @@ -3762,6 +3762,13 @@ sub _unblessed_for_log { my %data = map { $_ => $self->get_column($_) } $self->{_result}->result_source->columns; delete @data{qw(password lastseen updated_on)}; for my $key ( keys %data ) { + + # Koha::Object::AUTOLOAD calls set_column directly (bypassing DBIC deflation), + # so date/datetime columns set via Koha accessors may hold DateTime objects + # in _column_data. Stringify them so encode_json doesn't choke. + if ( ref $data{$key} && $data{$key}->isa('DateTime') ) { + $data{$key} = "$data{$key}"; + } delete $data{$key} unless defined $data{$key} && $data{$key} ne ''; } return \%data;