Bugzilla – Attachment 127289 Details for
Bug 28692
Reduce DB action_log table size
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Help
|
New Account
|
Log In
[x]
|
Forgot Password
Login:
[x]
[patch]
Bug 28700: Get from storage before log actions
Bug-28700-Get-from-storage-before-log-actions.patch (text/plain), 5.81 KB, created by
Jonathan Druart
on 2021-11-04 10:19:56 UTC
(
hide
)
Description:
Bug 28700: Get from storage before log actions
Filename:
MIME Type:
Creator:
Jonathan Druart
Created:
2021-11-04 10:19:56 UTC
Size:
5.81 KB
patch
obsolete
>From 90ea51fe491a572ce35203c31efd9c55f988c41c Mon Sep 17 00:00:00 2001 >From: Jonathan Druart <jonathan.druart@bugs.koha-community.org> >Date: Tue, 12 Oct 2021 11:44:12 +0200 >Subject: [PATCH] Bug 28700: Get from storage before log actions > >To make sure we have logging the values from DB. >It will reduce DB action_log table size when we log the full object and >it contains DateTime object. > >https://bugs.koha-community.org/show_bug.cgi?id=28692 >--- > C4/Log.pm | 9 +++++++++ > C4/Reserves.pm | 11 +++++------ > Koha/Hold.pm | 9 ++++----- > Koha/Item.pm | 3 +-- > 4 files changed, 19 insertions(+), 13 deletions(-) > >diff --git a/C4/Log.pm b/C4/Log.pm >index 5a9077de0dd..f40b7c09f92 100644 >--- a/C4/Log.pm >+++ b/C4/Log.pm >@@ -76,6 +76,15 @@ sub logaction { > $usernumber ||= 0; > $interface //= C4::Context->interface; > >+ if ( ref($infos) && ref($infos) !~ /HASH|ARRAY/ && $infos->isa('Koha::Object') ) { >+ $infos = $infos->get_from_storage if $infos->in_storage; >+ $infos = Dumper( $infos->unblessed ); >+ >+ if ( $infos->isa('Koha::Item') && $modulename eq 'CATALOGUING' && $actionname eq 'MODIFY' ) { >+ $infos = "item " . $infos; >+ } >+ } >+ > my $dbh = C4::Context->dbh; > my $sth=$dbh->prepare("Insert into action_logs (timestamp,user,module,action,object,info,interface) values (now(),?,?,?,?,?,?)"); > $sth->execute($usernumber,$modulename,$actionname,$objectnumber,$infos,$interface); >diff --git a/C4/Reserves.pm b/C4/Reserves.pm >index f2ee4639797..a42168bc727 100644 >--- a/C4/Reserves.pm >+++ b/C4/Reserves.pm >@@ -46,7 +46,6 @@ use Koha::Old::Hold; > use Koha::Patrons; > use Koha::Plugins; > >-use Data::Dumper qw( Dumper ); > use List::MoreUtils qw( any ); > > =head1 NAME >@@ -261,7 +260,7 @@ sub AddReserve { > )->store(); > $hold->set_waiting() if $found && $found eq 'W'; > >- logaction( 'HOLDS', 'CREATE', $hold->id, Dumper($hold->unblessed) ) >+ logaction( 'HOLDS', 'CREATE', $hold->id, $hold ) > if C4::Context->preference('HoldsLog'); > > my $reserve_id = $hold->id(); >@@ -1053,14 +1052,14 @@ sub ModReserve { > $hold->cancel({ cancellation_reason => $cancellation_reason }); > } > elsif ($hold->found && $hold->priority eq '0' && $date) { >- logaction( 'HOLDS', 'MODIFY', $hold->reserve_id, Dumper($hold->unblessed) ) >+ logaction( 'HOLDS', 'MODIFY', $hold->reserve_id, $hold ) > if C4::Context->preference('HoldsLog'); > > # The only column that can be updated for a found hold is the expiration date > $hold->expirationdate(dt_from_string($date))->store(); > } > elsif ($rank =~ /^\d+/ and $rank > 0) { >- logaction( 'HOLDS', 'MODIFY', $hold->reserve_id, Dumper($hold->unblessed) ) >+ logaction( 'HOLDS', 'MODIFY', $hold->reserve_id, $hold ) > if C4::Context->preference('HoldsLog'); > > my $properties = { >@@ -1122,7 +1121,7 @@ sub ModReserveFill { > } > ); > >- logaction( 'HOLDS', 'MODIFY', $hold->reserve_id, Dumper($hold->unblessed) ) >+ logaction( 'HOLDS', 'MODIFY', $hold->reserve_id, $hold ) > if C4::Context->preference('HoldsLog'); > > # FIXME Must call Koha::Hold->cancel ? => No, should call ->filled and add the correct log >@@ -1250,7 +1249,7 @@ sub ModReserveAffect { > }); > $std->execute($hold->reserve_id); > >- logaction( 'HOLDS', 'MODIFY', $hold->reserve_id, Dumper($hold->get_from_storage->unblessed) ) >+ logaction( 'HOLDS', 'MODIFY', $hold->reserve_id, $hold ) > if C4::Context->preference('HoldsLog'); > > return; >diff --git a/Koha/Hold.pm b/Koha/Hold.pm >index 26c41d7924d..9736dc527f0 100644 >--- a/Koha/Hold.pm >+++ b/Koha/Hold.pm >@@ -20,7 +20,6 @@ package Koha::Hold; > > use Modern::Perl; > >-use Data::Dumper qw( Dumper ); > use List::MoreUtils qw( any ); > > use C4::Context; >@@ -113,7 +112,7 @@ sub suspend_hold { > $self->suspend_until($date); > $self->store(); > >- logaction( 'HOLDS', 'SUSPEND', $self->reserve_id, Dumper( $self->unblessed ) ) >+ logaction( 'HOLDS', 'SUSPEND', $self->reserve_id, $self ) > if C4::Context->preference('HoldsLog'); > > return $self; >@@ -133,7 +132,7 @@ sub resume { > > $self->store(); > >- logaction( 'HOLDS', 'RESUME', $self->reserve_id, Dumper($self->unblessed) ) >+ logaction( 'HOLDS', 'RESUME', $self->reserve_id, $self ) > if C4::Context->preference('HoldsLog'); > > return $self; >@@ -150,7 +149,7 @@ sub delete { > > my $deleted = $self->SUPER::delete($self); > >- logaction( 'HOLDS', 'DELETE', $self->reserve_id, Dumper($self->unblessed) ) >+ logaction( 'HOLDS', 'DELETE', $self->reserve_id, $self ) > if C4::Context->preference('HoldsLog'); > > return $deleted; >@@ -568,7 +567,7 @@ sub cancel { > ); > } > >- C4::Log::logaction( 'HOLDS', 'CANCEL', $self->reserve_id, Dumper($self->unblessed) ) >+ C4::Log::logaction( 'HOLDS', 'CANCEL', $self->reserve_id, $self ) > if C4::Context->preference('HoldsLog'); > } > ); >diff --git a/Koha/Item.pm b/Koha/Item.pm >index 5fada53af8a..d70fbc3f8f5 100644 >--- a/Koha/Item.pm >+++ b/Koha/Item.pm >@@ -20,7 +20,6 @@ package Koha::Item; > use Modern::Perl; > > use List::MoreUtils qw( any ); >-use Data::Dumper qw( Dumper ); > > use Koha::Database; > use Koha::DateUtils qw( dt_from_string output_pref ); >@@ -205,7 +204,7 @@ sub store { > if ( $log_action && C4::Context->preference("CataloguingLog") ) { > $action eq 'create' > ? logaction( "CATALOGUING", "ADD", $self->itemnumber, "item" ) >- : logaction( "CATALOGUING", "MODIFY", $self->itemnumber, "item " . Dumper( $self->unblessed ) ); >+ : logaction( "CATALOGUING", "MODIFY", $self->itemnumber, $self ); > } > my $indexer = Koha::SearchEngine::Indexer->new({ index => $Koha::SearchEngine::BIBLIOS_INDEX }); > $indexer->index_records( $self->biblionumber, "specialUpdate", "biblioserver" ) >-- >2.25.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 28692
:
122683
|
122782
|
125692
|
127289
|
127446
|
127574
|
127575
|
127576
|
127577
|
127630
|
127639
|
127640
|
127641
|
127642
|
127645
|
127646
|
127647
|
127648
|
127649