Bugzilla – Attachment 122782 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 28692: log without indentation to decrease DB action_log table size
Bug-28692-log-without-indentation-to-decrease-DB-a.patch (text/plain), 6.18 KB, created by
Peter Vashchuk
on 2021-07-12 13:59:07 UTC
(
hide
)
Description:
Bug 28692: log without indentation to decrease DB action_log table size
Filename:
MIME Type:
Creator:
Peter Vashchuk
Created:
2021-07-12 13:59:07 UTC
Size:
6.18 KB
patch
obsolete
>From 13fba7008e2ad441fa63b53556bacd136bf77261 Mon Sep 17 00:00:00 2001 >From: Petro Vashchuk <stalkernoid@gmail.com> >Date: Mon, 12 Jul 2021 16:58:20 +0300 >Subject: [PATCH] Bug 28692: log without indentation to decrease DB action_log > table size > >Indentation symbols like spaces and newlines take up a large amount of >extra space. Example: fully indented action_log item MODIFY record >weighs from 1.6 to 370 KB while the version of it without any >indentation takes 1.1 to 46 KB accordingly. > >This changes logaction subroutine to perform a special transformation, >if$info came as known object, that adds Indent(0) parameter of >Data::Dumper to output without indentation. > >To reproduce for item: >1) edit any item you see fit, save it. >2) check the action_logs table and find there a newly created MODIFY >item row, "info" column of that contains dumped data, see that it has >indentation, optional: check and note about the size of it. >3) apply the patch. >4) edit that item again and save it afterwards. >5) "info" column of the newly created row should contain non-indented >text now. If you did check the size of the previous dump, compare it >with this new one, check the difference it makes. > >To reproduce for hold: >1) in syspref set HoldsLog to Log. >1) go to the biblio page and suspend and resume any hold you see fit. >2) check the action_logs table and find there a newly created SUSPEND >item row, "info" column of that contains dumped data, see that it has >indentation, optional: check and note about the size of it. >3) apply the patch. >4) edit that item again and save it afterwards. >5) "info" column of the newly created row should contain non-indented >text now. If you did check the size of the previous dump, compare it >with this new one, check the difference it makes. >--- > C4/Log.pm | 11 +++++++++++ > C4/Reserves.pm | 8 ++++---- > Koha/Hold.pm | 8 ++++---- > Koha/Item.pm | 2 +- > 4 files changed, 20 insertions(+), 9 deletions(-) > >diff --git a/C4/Log.pm b/C4/Log.pm >index dc3c63fa80..b600e7e52a 100644 >--- a/C4/Log.pm >+++ b/C4/Log.pm >@@ -69,6 +69,17 @@ number is set to 0, which is the same as the superlibrarian's number. > sub logaction { > my ($modulename, $actionname, $objectnumber, $infos, $interface)=@_; > >+ # Do special transformations if $info came as below-known object: >+ my $varname; >+ if ( ref $infos eq 'Koha::Hold' ) { >+ $varname = 'hold'; >+ } elsif ( ref $infos eq 'Koha::Item' ) { >+ $varname = 'item'; >+ } >+ if ($varname) { >+ $infos = Data::Dumper->new( [ $infos->unblessed ], [$varname] )->Indent(0)->Sortkeys(1)->Dump; >+ } >+ > # Get ID of logged in user. if called from a batch job, > # no user session exists and C4::Context->userenv() returns > # the scalar '0'. >diff --git a/C4/Reserves.pm b/C4/Reserves.pm >index 83222dc1c5..326182212b 100644 >--- a/C4/Reserves.pm >+++ b/C4/Reserves.pm >@@ -257,7 +257,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(); >@@ -1046,7 +1046,7 @@ sub ModReserve { > $hold->cancel({ cancellation_reason => $cancellation_reason }); > } > 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 = { >@@ -1108,7 +1108,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 >@@ -1236,7 +1236,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->get_from_storage ) > if C4::Context->preference('HoldsLog'); > > return; >diff --git a/Koha/Hold.pm b/Koha/Hold.pm >index bd5458f494..60b1fa3407 100644 >--- a/Koha/Hold.pm >+++ b/Koha/Hold.pm >@@ -114,7 +114,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; >@@ -134,7 +134,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; >@@ -151,7 +151,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; >@@ -569,7 +569,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 47a86eb0bb..110e8ff94b 100644 >--- a/Koha/Item.pm >+++ b/Koha/Item.pm >@@ -203,7 +203,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, "item " . $self ); > } > my $indexer = Koha::SearchEngine::Indexer->new({ index => $Koha::SearchEngine::BIBLIOS_INDEX }); > $indexer->index_records( $self->biblionumber, "specialUpdate", "biblioserver" ) >-- >2.31.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