Bug 28692: 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. Signed-off-by: Martin Renvoize <martin.renvoize@ptfs-europe.com> Signed-off-by: Marcel de Rooy <m.de.rooy@rijksmuseum.nl> Signed-off-by: Jonathan Druart <jonathan.druart@bugs.koha-community.org>
This commit is contained in:
parent
ff2fbfe35f
commit
de99b016d8
4 changed files with 19 additions and 13 deletions
|
@ -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);
|
||||
|
|
|
@ -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;
|
||||
|
|
|
@ -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');
|
||||
}
|
||||
);
|
||||
|
|
|
@ -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" )
|
||||
|
|
Loading…
Reference in a new issue