From ba313ae0bd0622fe6b46ca6c11977315e8b589ff Mon Sep 17 00:00:00 2001 From: phette23 Date: Mon, 30 Sep 2024 14:38:27 -0700 Subject: [PATCH] Bug 29238: Cataloging cron jobs are not logged Testing plan: 1. set CronjobLog to "Log" 2. Run the three cron jobs `perl misc/link_bibs_to_authorities.pl; perl misc/cronjobs/merge_authorities.pl -b; perl misc/migration_tools/remove_unused_authorities.pl --confirm` 3. Visit the log viewer /cgi-bin/koha/tools/viewlog.pl, select the "Cron jobs" module, & note it's empty 4. apply the patch 5. Repeat steps 2 & 3 but note the cron logs aren't empty squash --- misc/cronjobs/merge_authorities.pl | 3 +++ misc/link_bibs_to_authorities.pl | 4 ++++ misc/migration_tools/remove_unused_authorities.pl | 5 +++++ 3 files changed, 12 insertions(+) diff --git a/misc/cronjobs/merge_authorities.pl b/misc/cronjobs/merge_authorities.pl index 51cd4ef2b2..f8f8f457db 100755 --- a/misc/cronjobs/merge_authorities.pl +++ b/misc/cronjobs/merge_authorities.pl @@ -7,12 +7,14 @@ use Time::HiRes qw( gettimeofday ); use Koha::Script -cron; use C4::AuthoritiesMarc qw( GetAuthority merge ); +use C4::Log qw( cronlogaction ); use Koha::Authority::MergeRequests; use constant RESET_HOURS => 24; use constant REMOVE_DAYS => 30; my ( $params ); +my $command_line_options = join(" ", @ARGV); GetOptions( 'h' => \$params->{help}, 'v' => \$params->{verbose}, @@ -21,6 +23,7 @@ GetOptions( $|=1; # flushes output if ( $params->{batch} ) { + cronlogaction( { info => $command_line_options } ); handle_batch($params); } else { pod2usage(1); diff --git a/misc/link_bibs_to_authorities.pl b/misc/link_bibs_to_authorities.pl index 0315518168..650de1d8e3 100755 --- a/misc/link_bibs_to_authorities.pl +++ b/misc/link_bibs_to_authorities.pl @@ -24,6 +24,7 @@ use C4::Biblio qw( LinkBibHeadingsToAuthorities ModBiblio ); +use C4::Log qw( cronlogaction ); use Koha::Biblios; use Getopt::Long qw( GetOptions ); use Pod::Usage qw( pod2usage ); @@ -53,6 +54,7 @@ my $commit = 100; my $tagtolink; my $allowrelink = C4::Context->preference("LinkerRelink") // ''; +my $command_line_options = join(" ", @ARGV); my $result = GetOptions( 'v|verbose' => \$verbose, 't|test' => \$test_only, @@ -70,6 +72,8 @@ if ( not $result or $want_help ) { usage(); } +cronlogaction( { info => $command_line_options } ); + my $linker_module = "C4::Linker::" . ( C4::Context->preference("LinkerModule") || 'Default' ); unless ( can_load( modules => { $linker_module => undef } ) ) { diff --git a/misc/migration_tools/remove_unused_authorities.pl b/misc/migration_tools/remove_unused_authorities.pl index 0065a16e9f..4283cea2f2 100755 --- a/misc/migration_tools/remove_unused_authorities.pl +++ b/misc/migration_tools/remove_unused_authorities.pl @@ -25,12 +25,14 @@ use Modern::Perl; use Koha::Script; use C4::Context; use C4::AuthoritiesMarc qw( DelAuthority ); +use C4::Log qw( cronlogaction ); use Getopt::Long qw( GetOptions ); use Koha::SearchEngine::Search; my @authtypes; my ($confirm, $test, $want_help); +my $command_line_options = join(" ", @ARGV); GetOptions( 'aut|authtypecode:s' => \@authtypes, 'c|confirm' => \$confirm, @@ -42,6 +44,9 @@ if ( $want_help || !($test || $confirm) ) { print_usage(); exit 0; } + +cronlogaction( { info => $command_line_options } ); + if ($test) { print "*** Testing only, authorities will not be deleted. ***\n"; } -- 2.47.0