Bugzilla – Attachment 195036 Details for
Bug 40136
Record diff in action logs when modifying a patron
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Help
|
New Account
|
Log In
[x]
|
Forgot Password
Login:
[x]
[patch]
Bug 40136: (follow-up) Refactor MODIFY log to use _unblessed_for_log
db93564.patch (text/plain), 3.58 KB, created by
Martin Renvoize (ashimema)
on 2026-03-09 22:07:02 UTC
(
hide
)
Description:
Bug 40136: (follow-up) Refactor MODIFY log to use _unblessed_for_log
Filename:
MIME Type:
Creator:
Martin Renvoize (ashimema)
Created:
2026-03-09 22:07:02 UTC
Size:
3.58 KB
patch
obsolete
>From db93564c807234979cd560c5eed562baae3f311a Mon Sep 17 00:00:00 2001 >From: Martin Renvoize <martin.renvoize@openfifth.co.uk> >Date: Mon, 9 Mar 2026 22:05:08 +0000 >Subject: [PATCH] Bug 40136: (follow-up) Refactor MODIFY log to use > _unblessed_for_log > >Replace the manual unblessed + skip_fields + blessed-stringify logic in >the MODIFY actionlog section with calls to _unblessed_for_log, which >already handles all three concerns. This removes the need for @skip_fields, >the dateexpiry normalisation workaround, and the inline blessed checks. > >Also restrict the log_from/log_to hashrefs to only the changed keys, so >the diff column contains only fields that actually changed rather than >the full patron state. >--- > Koha/Patron.pm | 30 +++++------------------------- > 1 file changed, 5 insertions(+), 25 deletions(-) > >diff --git a/Koha/Patron.pm b/Koha/Patron.pm >index 7af330db6e8..b35d18dc522 100644 >--- a/Koha/Patron.pm >+++ b/Koha/Patron.pm >@@ -375,20 +375,12 @@ sub store { > > # Actionlogs > if ( C4::Context->preference("BorrowersLog") || C4::Context->preference("CardnumberLog") ) { >- my $from_storage = $self_from_storage->unblessed; >- my $from_object = $self->unblessed; >+ my $from_storage = $self_from_storage->_unblessed_for_log; >+ my $from_object = $self->_unblessed_for_log; > >- # Object's dateexpiry is a DateTime object which stringifies to iso8601 datetime, >- # but the column is only a date so we need to convert the datetime to just a date >- # to know if it has actually changed. >- $from_object->{dateexpiry} = dt_from_string( $from_object->{dateexpiry} )->ymd >- if $from_object->{dateexpiry}; >- >- my @skip_fields = (qw/lastseen updated_on password/); >- my @keys = C4::Context->preference("BorrowersLog") ? keys %{$from_storage} : ('cardnumber'); >+ my @keys = C4::Context->preference("BorrowersLog") ? keys %{$from_storage} : ('cardnumber'); > my $changed; > for my $key (@keys) { >- next if any { /$key/ } @skip_fields; > my $storage_value = $from_storage->{$key} // q{}; > my $object_value = $from_object->{$key} // q{}; > if ( ( $storage_value || $object_value ) >@@ -399,20 +391,8 @@ sub store { > } > > if ( defined($changed) ) { >- my %log_from = map { >- my $v = $from_storage->{$_}; >- $_ => ( blessed($v) ? "$v" : $v ) >- } grep { >- my $k = $_; >- !any { /$k/ } @skip_fields >- } keys %{$from_storage}; >- my %log_to = map { >- my $v = $from_object->{$_}; >- $_ => ( blessed($v) ? "$v" : $v ) >- } grep { >- my $k = $_; >- !any { /$k/ } @skip_fields >- } keys %{$from_object}; >+ my %log_from = map { $_ => $from_storage->{$_} } keys %{$changed}; >+ my %log_to = map { $_ => $from_object->{$_} } keys %{$changed}; > > logaction( "MEMBERS", "MODIFY", $self->borrowernumber, \%log_to, undef, \%log_from ) > if C4::Context->preference("BorrowersLog"); >-- >2.53.0 >
You cannot view the attachment while viewing its details because your browser does not support IFRAMEs.
View the attachment on a separate page
.
View Attachment As Diff
View Attachment As Raw
Actions:
View
|
Diff
|
Splinter Review
Attachments on
bug 40136
:
194872
|
194940
| 195036 |
195037