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 <martin.renvoize@openfifth.co.uk>
This commit is contained in:
parent
9e8eceb1a7
commit
eb36400a9b
|
|
@ -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;
|
||||
|
|
|
|||
Loading…
Reference in New Issue