@@ -, +, @@ that generated the given log cronjob that caused the change. --- C4/Log.pm | 10 ++++++++-- installer/data/mysql/atomicupdate/bug_30984.pl | 17 +++++++++++++++++ installer/data/mysql/kohastructure.sql | 1 + 3 files changed, 26 insertions(+), 2 deletions(-) create mode 100755 installer/data/mysql/atomicupdate/bug_30984.pl --- a/C4/Log.pm +++ a/C4/Log.pm @@ -27,6 +27,7 @@ use warnings; use Data::Dumper qw( Dumper ); use JSON qw( to_json ); use Scalar::Util qw( blessed ); +use File::Basename qw( basename ); use C4::Context; use Koha::Logger; @@ -89,9 +90,14 @@ sub logaction { } } + my $script = + $interface eq 'cron' ? basename($0) + : $interface eq 'commandline' ? basename($0) + : undef; + 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); + my $sth=$dbh->prepare("Insert into action_logs (timestamp,user,module,action,object,info,interface,script) values (now(),?,?,?,?,?,?,?)"); + $sth->execute($usernumber,$modulename,$actionname,$objectnumber,$infos,$interface,$script); $sth->finish; my $logger = Koha::Logger->get( --- a/installer/data/mysql/atomicupdate/bug_30984.pl +++ a/installer/data/mysql/atomicupdate/bug_30984.pl @@ -0,0 +1,17 @@ +use Modern::Perl; + +return { + bug_number => "30984", + description => "Log the cron script that generated an action log if there is one", + up => sub { + my ($args) = @_; + my ($dbh, $out) = @$args{qw(dbh out)}; + if( !column_exists( 'action_logs', 'script' ) ) { + $dbh->do(q{ + ALTER TABLE action_logs + ADD COLUMN script mediumtext COLLATE utf8mb4_unicode_ci DEFAULT NULL COMMENT 'the name of the cron script that caused this change' + AFTER interface + }); + } + }, +}; --- a/installer/data/mysql/kohastructure.sql +++ a/installer/data/mysql/kohastructure.sql @@ -175,6 +175,7 @@ CREATE TABLE `action_logs` ( `object` int(11) DEFAULT NULL COMMENT 'the object that the action was taken against (could be a borrowernumber, itemnumber, etc)', `info` mediumtext COLLATE utf8mb4_unicode_ci DEFAULT NULL COMMENT 'information about the action (usually includes SQL statement)', `interface` varchar(30) COLLATE utf8mb4_unicode_ci DEFAULT NULL COMMENT 'the context this action was taken in', + `script` mediumtext COLLATE utf8mb4_unicode_ci DEFAULT NULL COMMENT 'the name of the cron script that caused this change', PRIMARY KEY (`action_id`), KEY `timestamp_idx` (`timestamp`), KEY `user_idx` (`user`), --