Bugzilla – Attachment 165532 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) Tidy changes
Bug-25159-QA-follow-up-Tidy-changes.patch (text/plain), 6.08 KB, created by
Martin Renvoize
on 2024-04-25 11:55:09 UTC
(
hide
)
Description:
Bug 25159: (QA follow-up) Tidy changes
Filename:
MIME Type:
Creator:
Martin Renvoize
Created:
2024-04-25 11:55:09 UTC
Size:
6.08 KB
patch
obsolete
>From 4e75c85667847d2286d89b205d1039080a4c3997 Mon Sep 17 00:00:00 2001 >From: Martin Renvoize <martin.renvoize@ptfs-europe.com> >Date: Thu, 25 Apr 2024 12:53:10 +0100 >Subject: [PATCH] Bug 25159: (QA follow-up) Tidy changes > >Signed-off-by: Martin Renvoize <martin.renvoize@ptfs-europe.com> >--- > C4/Log.pm | 38 +++++++++---------- > .../data/mysql/atomicupdate/bug_25159.pl | 6 +-- > t/db_dependent/Log.t | 12 +++--- > 3 files changed, 29 insertions(+), 27 deletions(-) > >diff --git a/C4/Log.pm b/C4/Log.pm >index f287e84d072..d7ad162c4cb 100644 >--- a/C4/Log.pm >+++ b/C4/Log.pm >@@ -2,7 +2,6 @@ package C4::Log; > > #package to deal with Logging Actions in DB > >- > # Copyright 2000-2002 Katipo Communications > # Copyright 2011 MJ Ray and software.coop > # >@@ -24,11 +23,11 @@ package C4::Log; > use strict; > use warnings; > >-use Data::Dumper qw( Dumper ); >+use Data::Dumper qw( Dumper ); > use File::Basename qw( basename ); >-use JSON qw( to_json encode_json ); >-use Scalar::Util qw( blessed ); >-use Struct::Diff qw( diff ); >+use JSON qw( to_json encode_json ); >+use Scalar::Util qw( blessed ); >+use Struct::Diff qw( diff ); > > use C4::Context; > use Koha::Logger; >@@ -37,9 +36,9 @@ use Koha::ActionLogs; > use vars qw(@ISA @EXPORT); > > BEGIN { >- require Exporter; >- @ISA = qw(Exporter); >- @EXPORT = qw(logaction cronlogaction); >+ require Exporter; >+ @ISA = qw(Exporter); >+ @EXPORT = qw(logaction cronlogaction); > } > > =head1 NAME >@@ -71,33 +70,34 @@ number is set to 0, which is the same as the superlibrarian's number. > > #' > sub logaction { >- my ($modulename, $actionname, $objectnumber, $infos, $interface, $original )=@_; >+ my ( $modulename, $actionname, $objectnumber, $infos, $interface, $original ) = @_; > > my $updated; > > # Get ID of logged in user. if called from a batch job, > # no user session exists and C4::Context->userenv() returns > # the scalar '0'. >- my $userenv = C4::Context->userenv(); >- my $usernumber = (ref($userenv) eq 'HASH') ? $userenv->{'number'} : 0; >+ my $userenv = C4::Context->userenv(); >+ my $usernumber = ( ref($userenv) eq 'HASH' ) ? $userenv->{'number'} : 0; > $usernumber ||= 0; > $interface //= C4::Context->interface; > >- if( blessed($infos) && $infos->isa('Koha::Object') ) { >- $infos = $infos->get_from_storage if $infos->in_storage; >+ if ( blessed($infos) && $infos->isa('Koha::Object') ) { >+ $infos = $infos->get_from_storage if $infos->in_storage; > $updated = $infos->unblessed; > local $Data::Dumper::Sortkeys = 1; > > if ( $infos->isa('Koha::Item') && $modulename eq 'CATALOGUING' && $actionname eq 'MODIFY' ) { >- $infos = "item " . Dumper( $updated ); >+ $infos = "item " . Dumper($updated); > } else { >- $infos = Dumper( $updated ); >+ $infos = Dumper($updated); > } > } else { > $updated = $infos; > } > >- my $script = ( $interface eq 'cron' or $interface eq 'commandline' ) >+ my $script = >+ ( $interface eq 'cron' or $interface eq 'commandline' ) > ? basename($0) > : undef; > >@@ -172,11 +172,11 @@ Logs the path and name of the calling script plus the information privided by pa > #' > sub cronlogaction { > my $params = shift; >- my $info = $params->{info}; >+ my $info = $params->{info}; > my $action = $params->{action}; > $action ||= "Run"; >- my $loginfo = (caller(0))[1]; >- $loginfo .= ' ' . $info if $info; >+ my $loginfo = ( caller(0) )[1]; >+ $loginfo .= ' ' . $info if $info; > logaction( 'CRONJOBS', $action, $$, $loginfo ) if C4::Context->preference('CronjobLog'); > } > >diff --git a/installer/data/mysql/atomicupdate/bug_25159.pl b/installer/data/mysql/atomicupdate/bug_25159.pl >index a2c24e74079..7a6d995ed6f 100755 >--- a/installer/data/mysql/atomicupdate/bug_25159.pl >+++ b/installer/data/mysql/atomicupdate/bug_25159.pl >@@ -1,11 +1,11 @@ > use Modern::Perl; > > return { >- bug_number => "251159", >+ bug_number => "251159", > description => "Add action logs should be stored in JSON ( and as a diff of the change )", >- up => sub { >+ up => sub { > my ($args) = @_; >- my ($dbh, $out) = @$args{qw(dbh out)}; >+ my ( $dbh, $out ) = @$args{qw(dbh out)}; > > $dbh->do(q{ALTER TABLE action_logs ADD COLUMN diff LONGTEXT NULL DEFAULT NULL AFTER trace;}); > say $out "Added column 'action_logs.diff'"; >diff --git a/t/db_dependent/Log.t b/t/db_dependent/Log.t >index f1bec5108e0..0a1f695ef78 100755 >--- a/t/db_dependent/Log.t >+++ b/t/db_dependent/Log.t >@@ -199,19 +199,21 @@ subtest 'Reduce log size by unblessing Koha objects' => sub { > subtest 'Test storing diff of objects' => sub { > plan tests => 2; > >- my $builder = t::lib::TestBuilder->new; >- my $item = $builder->build_sample_item; >- my $original = $item->unblessed(); >+ 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 $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; >+ $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' ); > }; >-- >2.44.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 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