Bug 26744: Cosolidate changes and change log format

Signed-off-by: Lucas Gass <lucas@bywatersolutions.com>
Signed-off-by: Katrin Fischer <katrin.fischer@bsz-bw.de>
This commit is contained in:
David Gustafsson 2025-02-28 13:06:15 +01:00 committed by Katrin Fischer
parent d4c11de65d
commit 09801ed302
Signed by: kfischer
GPG key ID: 0EF6E2C03357A834
2 changed files with 13 additions and 10 deletions

View file

@ -2256,11 +2256,12 @@ sub add_extended_attribute {
)->store;
if ( C4::Context->preference("BorrowersLog") ) {
my $code = $attribute->{code};
logaction(
"MEMBERS",
"MODIFY",
$self->borrowernumber,
"Patron attribute " . $attribute->{code} . ": " . to_json( $change, { pretty => 1, canonical => 1 } )
to_json( { "attribute.$code" => $change }, { pretty => 1, canonical => 1 } )
);
}
@ -2325,6 +2326,7 @@ sub extended_attributes {
my $schema = $self->_result->result_source->schema;
$schema->txn_do(
sub {
my $all_changes = {};
while ( my ( $repeatable, $changes ) = each %attribute_changes ) {
while ( my ( $code, $change ) = each %{$changes} ) {
$change->{before} //= [];
@ -2348,14 +2350,7 @@ sub extended_attributes {
$attribute->store() if ( $attribute->code eq $code );
}
if ( C4::Context->preference("BorrowersLog") ) {
logaction(
"MEMBERS",
"MODIFY",
$self->borrowernumber,
"Patron attribute "
. $code . ": "
. to_json( $change, { pretty => 1, canonical => 1 } )
);
$all_changes->{"attribute.$code"} = $change;
}
}
}
@ -2386,6 +2381,14 @@ sub extended_attributes {
type => $type,
) if !$new_types->{$type};
}
if ( %{$all_changes} ) {
logaction(
"MEMBERS",
"MODIFY",
$self->borrowernumber,
to_json( $all_changes, { pretty => 1, canonical => 1 } )
);
}
}
);
}

View file

@ -543,7 +543,7 @@ subtest 'action log tests' => sub {
}
}
}
return "Patron attribute " . $code . ": " . to_json( $change, { pretty => 1, canonical => 1 } );
return to_json( { "attribute.$code" => $change }, { pretty => 1, canonical => 1 } );
};
my $patron = $builder->build_object( { class => 'Koha::Patrons' } );