Bugzilla – Attachment 164601 Details for
Bug 25159
Action logs should be stored in JSON (and as a diff of the change)
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Help
|
New Account
|
Log In
[x]
|
Forgot Password
Login:
[x]
[patch]
Bug 25159: (QA follow-up) Allow passing of 'original' as hashref or Koha::Object
0005-Bug-25159-QA-follow-up-Allow-passing-of-original-as-.patch (text/plain), 2.87 KB, created by
Emmi Takkinen
on 2024-04-10 10:58:03 UTC
(
hide
)
Description:
Bug 25159: (QA follow-up) Allow passing of 'original' as hashref or Koha::Object
Filename:
MIME Type:
Creator:
Emmi Takkinen
Created:
2024-04-10 10:58:03 UTC
Size:
2.87 KB
patch
obsolete
>From 0d445af49c3ce61262c5974d33a75c4982bec399 Mon Sep 17 00:00:00 2001 >From: Kyle M Hall <kyle@bywatersolutions.com> >Date: Tue, 12 Dec 2023 12:02:53 -0500 >Subject: [PATCH 5/5] Bug 25159: (QA follow-up) Allow passing of 'original' as > hashref or Koha::Object > >Signed-off-by: Emmi Takkinen <emmi.takkinen@koha-suomi.fi> >--- > C4/Log.pm | 8 ++++++-- > t/db_dependent/Log.t | 9 ++++++++- > 2 files changed, 14 insertions(+), 3 deletions(-) > >diff --git a/C4/Log.pm b/C4/Log.pm >index cc3811a15b..f287e84d07 100644 >--- a/C4/Log.pm >+++ b/C4/Log.pm >@@ -60,7 +60,7 @@ The functions in this module perform various functions in order to log all the o > > =item logaction > >- &logaction($modulename, $actionname, $objectnumber, $infos, $interface, $hashref_of_original); >+ &logaction($modulename, $actionname, $objectnumber, $infos, $interface, $original_as_hashref_or_object); > > Adds a record into action_logs table to report the different changes upon the database. > Each log entry includes the number of the user currently logged in. For batch >@@ -118,7 +118,11 @@ sub logaction { > } > my $trace = @trace ? to_json( \@trace, { utf8 => 1, pretty => 0 } ) : undef; > >- my $diff = ( $original && ref $updated eq 'HASH' ) ? encode_json( diff( $original, $updated, noU => 1 ) ) : undef; >+ my $diff = undef; >+ $diff = encode_json( diff( $original->unblessed, $updated, noU => 1 ) ) >+ if blessed($original) && $original->isa('Koha::Object'); >+ $diff //= encode_json( diff( $original, $updated, noU => 1 ) ) >+ if $original && ref $updated eq 'HASH'; > > Koha::ActionLog->new( > { >diff --git a/t/db_dependent/Log.t b/t/db_dependent/Log.t >index b870421856..f1bec5108e 100755 >--- a/t/db_dependent/Log.t >+++ b/t/db_dependent/Log.t >@@ -197,16 +197,23 @@ subtest 'Reduce log size by unblessing Koha objects' => sub { > }; > > subtest 'Test storing diff of objects' => sub { >- plan tests => 1; >+ plan tests => 2; > > my $builder = t::lib::TestBuilder->new; > my $item = $builder->build_sample_item; > my $original = $item->unblessed(); >+ my $original_item = $item->get_from_storage(); > $item->barcode('_MY_TEST_BARCODE_')->store(); >+ > logaction( 'MY_MODULE', 'TEST01', $item->itemnumber, $item, 'opac', $original ); > my $logs = Koha::ActionLogs->search({ module => 'MY_MODULE', action => 'TEST01', object => $item->itemnumber })->next; > my $diff = decode_json( $logs->diff ); > is( $diff->{D}->{barcode}->{N}, '_MY_TEST_BARCODE_', 'Diff of changes logged successfully' ); >+ >+ logaction( 'MY_MODULE', 'TEST02', $item->itemnumber, $item, 'opac', $original_item ); >+ $logs = Koha::ActionLogs->search({ module => 'MY_MODULE', action => 'TEST02', object => $item->itemnumber })->next; >+ $diff = decode_json( $logs->diff ); >+ is( $diff->{D}->{barcode}->{N}, '_MY_TEST_BARCODE_', 'Diff of changes logged successfully' ); > }; > > $schema->storage->txn_rollback; >-- >2.34.1 >
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 25159
:
153600
|
153601
|
153602
|
153603
|
153604
|
153606
|
153607
|
153608
|
153609
|
153611
|
153612
|
153613
|
153614
|
153637
|
153643
|
153644
|
153645
|
153646
|
159758
|
164597
|
164598
|
164599
|
164600
|
164601
|
165527
|
165528
|
165529
|
165530
|
165531
|
165532
|
166219