Bug 42030: (follow-up) Don't diff undefined fields

This patch updates the diff for ADD/CREATE and DELETE logactions to
exclude undefined fields from the diff.

Signed-off-by: Lisette Scheer <lisette@bywatersolutions.com>
Signed-off-by: Lucas Gass <lucas@bywatersolutions.com>
(cherry picked from commit d095599447)
Signed-off-by: Jacob O'Mara <Jacob.omara@openfifth.co.uk>
This commit is contained in:
Martin Renvoize 2026-03-26 16:13:42 +01:00 committed by Jacob O'Mara
parent 4fdcd10eeb
commit 890f03c3a2
No known key found for this signature in database
1 changed files with 17 additions and 2 deletions

View File

@ -123,13 +123,28 @@ sub logaction {
if ( $actionname =~ /^(ADD|CREATE)$/ ) {
# Log diff against empty hashref for newly created objects
$updated = $is_object ? $original->unblessed : $original;
$updated = $is_object ? $original->unblessed : $original;
for my $key ( keys %{$updated} ) {
if ( defined $updated->{$key} && $updated->{$key} ne '' ) {
$updated->{$key} = "$updated->{$key}" if blessed( $updated->{$key} );
} else {
delete $updated->{$key};
}
}
$original = {};
} elsif ( $actionname eq 'DELETE' ) {
# Log diff for deleted objects against empty hashref
$original = $is_object ? $original->unblessed : $original;
$updated = {};
for my $key ( keys %{$original} ) {
if ( defined $original->{$key} && $original->{$key} ne '' ) {
$original->{$key} = "$original->{$key}" if blessed( $original->{$key} );
} else {
delete $original->{$key};
}
}
$updated = {};
} else {
# Log diff against hashref of pre-modified object if passed in