Bug 31203: Alter other cronjobs that currenlty use cronlogaction

Added command line ooption logging and completion logging where
cronlogaction was already imported. We should probably standardize all
cronjobs, but this is a start

One cron didn't log on confirm, likely we need to update all crons to log
if confirm, and possibly not log if running in test mode? Another bug as well

Signed-off-by: David Nind <david@davidnind.com>

Signed-off-by: Marcel de Rooy <m.de.rooy@rijksmuseum.nl>
Signed-off-by: Tomas Cohen Arazi <tomascohen@theke.io>
This commit is contained in:
Nick Clemens 2022-08-05 14:11:55 +00:00 committed by Tomas Cohen Arazi
parent 7749e73526
commit 906d5b1a85
Signed by: tomascohen
GPG key ID: 0A272EA1B2F3C15F
32 changed files with 153 additions and 32 deletions

View file

@ -545,6 +545,7 @@ jQuery.fn.dataTable.ext.errMode = function(settings, note, message) {
'beforeSend': function(xhr, settings) {
this._xhr = xhr;
if(options.embed) {
console.log(Array.isArray(options.embed));
xhr.setRequestHeader('x-koha-embed', Array.isArray(options.embed)?options.embed.join(','):options.embed);
}
if(options.header_filter && options.query_parameters) {

View file

@ -22,6 +22,10 @@ use Koha::Checkouts;
use Koha::Script -cron;
use C4::Log qw( cronlogaction );
cronlogaction();
my $command_line_options = join(" ",@ARGV);
cronlogaction({ info => $command_line_options });
Koha::Checkouts->automatic_checkin;
cronlogaction({ action => 'End', info => "COMPLETED" });
Koha::Checkouts->automatic_checkin;

View file

@ -11,6 +11,8 @@ use C4::Context;
use C4::Items;
use C4::Log qw( cronlogaction );
my $command_line_options = join(" ",@ARGV);
# Getting options
my ( $verbose, $help, $confirm );
my $result = GetOptions(
@ -28,7 +30,7 @@ my $rules = eval { JSON::from_json( $syspref_content ) };
pod2usage({ -message => "Unable to load the configuration : $@", -exitval => 1 })
if $@;
cronlogaction();
cronlogaction({ info => $command_line_options });
my $report = C4::Items::ToggleNewStatus( { rules => $rules, report_only => not $confirm } );
@ -49,6 +51,8 @@ if ( $verbose ) {
}
}
cronlogaction({ action => 'End', info => "COMPLETED" });
exit(0);
__END__

View file

@ -87,6 +87,8 @@ use Koha::Checkouts;
use Koha::Libraries;
use Koha::Patrons;
my $command_line_options = join(" ",@ARGV);
my ( $help, $send_notices, $verbose, $confirm, $digest_per_branch );
GetOptions(
'h|help' => \$help,
@ -127,7 +129,7 @@ To change this, edit the "EnhancedMessagingPreferences" syspref.
END_WARN
}
cronlogaction();
cronlogaction({ info => $command_line_options });
$verbose = 1 unless $verbose or $confirm;
print "Test run only\n" unless $confirm;
@ -285,6 +287,8 @@ if ( $send_notices && $confirm ) {
}
}
cronlogaction({ action => 'End', info => "COMPLETED" });
=head1 METHODS
=head2 send_digests

View file

@ -43,6 +43,8 @@ USAGE
exit $_[0];
}
my $command_line_options = join(" ",@ARGV);
my ( $help, $days, $verbose );
GetOptions(
@ -60,7 +62,7 @@ if ( !$days ) {
usage(1);
}
cronlogaction();
cronlogaction({ info => $command_line_options });
my $date = dt_from_string->subtract( days => $days );
@ -81,4 +83,6 @@ $rows = Koha::Old::Holds
$verbose and print int($rows) . " holds anonymised.\n";
cronlogaction({ action => 'End', info => "COMPLETED" });
exit(0);

View file

@ -15,6 +15,8 @@ use Getopt::Long;
use C4::Log;
use Koha::Biblios;
my $command_line_options = join(" ",@ARGV);
my ( $input_marc_file, $number) = ('',0);
my ($version, $confirm,$field,$batch,$max_digits,$cloud_tag);
GetOptions(
@ -57,7 +59,7 @@ my $browser_subfield = $2;
warn "browser : $browser_tag / $browser_subfield" unless $batch;
die "no cloud or browser field/subfield defined : nothing to do !" unless $browser_tag or $cloud_tag;
cronlogaction();
cronlogaction({ info => $command_line_options });
my $dbh = C4::Context->dbh;
@ -165,6 +167,7 @@ if ($cloud_tag) {
my $timeneeded = time() - $starttime;
print "$i records done in $timeneeded seconds\n" unless $batch;
cronlogaction({ action => 'End', info => "COMPLETED" });
sub dewey_french {
return {

View file

@ -37,6 +37,8 @@ use Getopt::Long qw( GetOptions );
my $hours = 0;
my $command_line_options = join(" ",@ARGV);
GetOptions( 'h|hours=s' => \$hours, );
my $usage = << 'ENDUSAGE';
@ -58,7 +60,7 @@ unless ($hours) {
die "ERROR: No --hours (-h) option defined";
}
cronlogaction();
cronlogaction({ info => $command_line_options });
my $query = "SELECT itemnumber FROM items WHERE location = 'CART' AND TIMESTAMPDIFF(HOUR, items.timestamp, NOW() ) > ?";
my $sth = C4::Context->dbh->prepare($query);
@ -66,3 +68,5 @@ $sth->execute($hours);
while (my ($itemnumber) = $sth->fetchrow_array) {
CartToShelf($itemnumber);
}
cronlogaction({ action => 'End', info => "COMPLETED" });

View file

@ -149,6 +149,8 @@ my $cards;
my @log_modules;
my @preserve_logs;
my $command_line_options = join(" ",@ARGV);
GetOptions(
'h|help' => \$help,
'confirm' => \$confirm,
@ -249,7 +251,7 @@ if ($pDebarments && $allDebarments) {
say "Confirm flag not passed, running in dry-run mode..." unless $confirm;
cronlogaction() unless $confirm;
cronlogaction({ info => $command_line_options });
my $dbh = C4::Context->dbh();
my $sth;
@ -673,6 +675,8 @@ if ($cards) {
}
}
cronlogaction({ action => 'End', info => "COMPLETED" });
exit(0);
sub RemoveOldSessions {

View file

@ -33,6 +33,9 @@ use C4::Log qw( cronlogaction );
my $verbose = 0;
my $help = 0;
my $conf = '';
my $command_line_options = join(" ",@ARGV);
GetOptions(
'verbose' => \$verbose,
'help' => \$help,
@ -46,7 +49,7 @@ sub usage {
usage() if $help || !$conf;
cronlogaction();
cronlogaction({ info => $command_line_options });
my @clouds;
print "Reading configuration file: $conf\n" if $verbose;
@ -90,6 +93,7 @@ for my $cloud ( @clouds ) {
$set_new_context && restore_context C4::Context;
}
cronlogaction({ action => 'End', info => "COMPLETED" });
package ZebraIndex;

View file

@ -14,6 +14,8 @@ use C4::Log qw( cronlogaction );
my ( $help, $verbose, $not_borrowed_since, $expired_before, $last_seen,
@category_code, $branchcode, $file, $confirm );
my $command_line_options = join(" ",@ARGV);
GetOptions(
'h|help' => \$help,
'v|verbose' => \$verbose,
@ -44,7 +46,7 @@ unless ( $not_borrowed_since or $expired_before or $last_seen or @category_code
pod2usage(q{At least one filter is mandatory});
}
cronlogaction();
cronlogaction({ info => $command_line_options });
my @file_members;
if ($file) {
@ -139,6 +141,8 @@ for my $member (@$members) {
say $confirm ? "$deleted patrons deleted" : "$deleted patrons would have been deleted" if $verbose;
cronlogaction({ action => 'End', info => "COMPLETED" });
=head1 NAME
delete_patrons - This script deletes patrons

View file

@ -49,6 +49,8 @@ my $output_dir;
my $log;
my $maxdays;
my $command_line_options = join(" ",@ARGV);
GetOptions(
'h|help' => \$help,
'v|verbose' => \$verbose,
@ -90,7 +92,7 @@ catch {
exit;
};
cronlogaction();
cronlogaction({ info => $command_line_options });
my @borrower_fields =
qw(cardnumber categorycode surname firstname email phone address citystate);
@ -200,6 +202,8 @@ Number of Overdue Items:
EOM
}
cronlogaction({ action => 'End', info => "COMPLETED" });
sub set_holiday {
my ( $branch, $dt ) = @_;

View file

@ -29,6 +29,8 @@ my (
@emails,
);
my $command_line_options = join(" ",@ARGV);
$send = 1;
GetOptions(
'h|help' => \$help,
@ -72,7 +74,7 @@ if ( $ods and @letter_codes != 1 ) {
$delimiter ||= q|,|;
cronlogaction();
cronlogaction({ info => $command_line_options });
my $today_iso = output_pref( { dt => dt_from_string, dateonly => 1, dateformat => 'iso' } ) ;
my $today_syspref = output_pref( { dt => dt_from_string, dateonly => 1 } );
@ -142,6 +144,8 @@ if ( @emails ) {
}
}
cronlogaction({ action => 'End', info => "COMPLETED" });
sub print_notices {
my ( $params ) = @_;

View file

@ -26,6 +26,9 @@ use Koha::Script -cron;
use C4::Reserves qw(AutoUnsuspendReserves);
use C4::Log qw( cronlogaction );
cronlogaction();
my $command_line_options = join(" ",@ARGV);
cronlogaction({ info => $command_line_options });
AutoUnsuspendReserves();
cronlogaction({ action => 'End', info => "COMPLETED" });

View file

@ -13,7 +13,9 @@ use Koha::Script -cron;
use C4::HoldsQueue qw(CreateQueue);
use C4::Log qw( cronlogaction );
cronlogaction();
my $command_line_options = join(" ",@ARGV);
cronlogaction({ info => $command_line_options });
CreateQueue();
cronlogaction({ action => 'End', info => "COMPLETED" });

View file

@ -65,12 +65,16 @@ Optionally adds a reason for cancellation (which will trigger a notice to be sen
my $help = 0;
my $reason;
my $command_line_options = join(" ",@ARGV);
GetOptions(
'help|?' => \$help,
'reason=s' => \$reason
) or pod2usage(1);
pod2usage(1) if $help;
cronlogaction();
cronlogaction({ info => $command_line_options });
C4::Reserves::CancelExpiredReserves($reason);
cronlogaction({ action => 'End', info => "COMPLETED" });

View file

@ -80,6 +80,8 @@ my $use_calendar = 0;
my $verbose = 0;
my $confirm = 0;
my $command_line_options = join(" ",@ARGV);
GetOptions(
'h|help|?' => \$help,
'days=s' => \$days,
@ -99,6 +101,9 @@ qq{\nError: You must specify a value for days waiting to cancel holds.\n},
}
);
}
cronlogaction({ info => $command_line_options });
warn "Running in test mode, no actions will be taken" unless ($confirm);
$verbose and warn "Looking for unfilled holds placed $days or more days ago\n";
@ -136,3 +141,5 @@ foreach my $branch (@branchcodes) {
}
}
cronlogaction({ action => 'End', info => "COMPLETED" });

View file

@ -176,6 +176,8 @@ my $date_input;
my $opt_out = 0;
my @mtts;
my $command_line_options = join(" ",@ARGV);
GetOptions(
'help|?' => \$help,
'man' => \$man,
@ -194,7 +196,7 @@ pod2usage( -verbose => 2 ) if $man;
$lettercode ||= 'HOLD_REMINDER';
cronlogaction();
cronlogaction({ info => $command_line_options });
# Unless a delay is specified by the user we target all waiting holds
unless (defined $days) {
@ -313,3 +315,5 @@ foreach my $branchcode (@branchcodes) { #BEGIN BRANCH LOOP
} #END BRANCH LOOP
cronlogaction({ action => 'End', info => "COMPLETED" });

View file

@ -53,6 +53,8 @@ my $list_categories = 0;
my $list_itemtypes = 0;
my @skip_lost_values;
my $command_line_options = join(" ",@ARGV);
GetOptions(
'l|lost=s%' => \$lost,
'c|charge=s' => \$charge,
@ -278,7 +280,7 @@ unless ($confirm) {
print "### TEST MODE -- NO ACTIONS TAKEN ###\n";
}
cronlogaction();
cronlogaction({ info => $command_line_options });
# In my opinion, this line is safe SQL to have outside the API. --atz
our $bounds_sth = C4::Context->dbh->prepare("SELECT DATE_SUB(CURDATE(), INTERVAL ? DAY)");
@ -443,3 +445,5 @@ if (!$quiet){
summarize (\@report, 1);
print "\nTOTAL: $total items\n";
}
cronlogaction({ action => 'End', info => "COMPLETED" });

View file

@ -158,6 +158,8 @@ my $after = 0;
my ( $branch, $letter_type );
my @where;
my $command_line_options = join(" ",@ARGV);
GetOptions(
'help|?' => \$help,
'man' => \$man,
@ -174,7 +176,7 @@ GetOptions(
pod2usage( -verbose => 2 ) if $man;
pod2usage(1) if $help || !$confirm;
cronlogaction();
cronlogaction({ info => $command_line_options });
my $expdays = C4::Context->preference('MembershipExpiryDaysNotice');
if( !$expdays ) {
@ -225,3 +227,5 @@ while ( my $recent = $upcoming_mem_expires->next ) {
});
}
}
cronlogaction({ action => 'End', info => "COMPLETED" });

View file

@ -309,6 +309,8 @@ my @myborcat;
my @myborcatout;
my ( $date_input, $today );
my $command_line_options = join(" ",@ARGV);
GetOptions(
'help|?' => \$help,
'man' => \$man,
@ -331,7 +333,7 @@ GetOptions(
) or pod2usage(2);
pod2usage(1) if $help;
pod2usage( -verbose => 2 ) if $man;
cronlogaction() unless $test_mode;
cronlogaction({ info => $command_line_options });
if ( defined $csvfilename && $csvfilename =~ /^-/ ) {
warn qq(using "$csvfilename" as filename, that seems odd);
@ -937,3 +939,4 @@ sub prepare_letter_for_printing {
return $return;
}
cronlogaction({ action => 'End', info => "COMPLETED" });

View file

@ -25,8 +25,6 @@ use Pod::Usage qw( pod2usage );
use C4::Log qw( cronlogaction );
use C4::Reports::Guided qw( EmailReport );
cronlogaction();
=head1 NAME
patron_emailer.pl
@ -119,6 +117,8 @@ my $error_msgs = {
NO_BOR => "There is no borrower with borrowernumber "
};
my $command_line_options = join(" ",@ARGV);
GetOptions(
'help|?' => \$help,
'report=i' => \$report_id,
@ -133,6 +133,8 @@ GetOptions(
pod2usage(1) if $help;
pod2usage(1) unless $report_id && $notice && $module;
cronlogaction({ info => $command_line_options });
my ( $emails, $errors ) = C4::Reports::Guided::EmailReport({
email => $email,
from => $from,
@ -169,3 +171,5 @@ if( $verbose || !$commit ){
}
}
}
cronlogaction({ action => 'End', info => "COMPLETED" });

View file

@ -10,7 +10,8 @@ use Koha::Logger;
use Koha::Plugins;
use Koha::Script -cron;
cronlogaction();
my $command_line_options = join(" ",@ARGV);
cronlogaction({ info => $command_line_options });
my $logger = Koha::Logger->get();
if ( C4::Context->config("enable_plugins") ) {
@ -31,6 +32,8 @@ if ( C4::Context->config("enable_plugins") ) {
}
}
cronlogaction({ action => 'End', info => "COMPLETED" });
=head1 NAME
plugins_nightly.pl - Run nightly tasks specified by plugins

View file

@ -35,6 +35,8 @@ my $verbose = 0;
my $type = q{};
my $letter_code;
my $command_line_options = join(" ",@ARGV);
GetOptions(
'u|username:s' => \$username,
'p|password:s' => \$password,
@ -79,7 +81,7 @@ catch {
exit;
};
cronlogaction();
cronlogaction({ info => $command_line_options });
if ( C4::Context->config("enable_plugins") ) {
my @plugins = Koha::Plugins->new->GetPlugins({
@ -117,3 +119,4 @@ C4::Letters::SendQueuedMessages(
}
);
cronlogaction({ action => 'End', info => "COMPLETED" });

View file

@ -28,6 +28,8 @@ use C4::Context;
my ( $help, $days, $confirm );
my $command_line_options = join(" ",@ARGV);
GetOptions(
'help|?' => \$help,
'days:i' => \$days,
@ -57,8 +59,11 @@ if( !$confirm || $help || !defined($days) ) {
print "No confirm parameter passed!\n\n" if !$confirm && !$help;
print $usage;
} elsif( $days and $days > 0 ) {
cronlogaction( " ( days: $days )");
$command_line_options .= " ( effective days = $days )";
cronlogaction({ info => $command_line_options });
DelSuggestionsOlderThan($days);
} else {
warn "This script requires a positive number of days. Aborted.\n";
}
cronlogaction({ action => 'End', info => "COMPLETED" });

View file

@ -35,7 +35,9 @@ use Koha::DateUtils qw( dt_from_string );
use Koha::Recalls;
use C4::Log;
cronlogaction();
my $command_line_options = join(" ",@ARGV);
cronlogaction({ info => $command_line_options });
my $recalls = Koha::Recalls->search({ completed => 0 });
while( my $recall = $recalls->next ) {
@ -66,3 +68,5 @@ while( my $recall = $recalls->next ) {
}
}
}
cronlogaction({ action => 'End', info => "COMPLETED" });

View file

@ -34,7 +34,9 @@ use Koha::Checkouts;
use Koha::Recalls;
use C4::Log;
cronlogaction();
my $command_line_options = join(" ",@ARGV);
cronlogaction({ info => $command_line_options });
my $recalls = Koha::Recalls->search({ status => 'R' });
while( my $recall = $recalls->next ) {
@ -42,3 +44,5 @@ while( my $recall = $recalls->next ) {
$recall->set_overdue({ interface => 'COMMANDLINE' });
}
}
cronlogaction({ action => 'End', info => "COMPLETED" });

View file

@ -64,13 +64,15 @@ use Koha::Patrons;
my $help = 0;
my $verbose = 0;
my $command_line_options = join(" ",@ARGV);
GetOptions(
'help' => \$help,
'verbose' => \$verbose
) or pod2usage(2);
pod2usage(1) if $help;
cronlogaction();
cronlogaction({ info => $command_line_options });
my @patron_ids = Koha::Account::Lines->search(
{
@ -111,6 +113,8 @@ while (my $patron = $patrons->next) {
}
}
cronlogaction({ action => 'End', info => "COMPLETED" });
1;
__END__

View file

@ -186,6 +186,8 @@ my $username = undef;
my $password = undef;
my $method = 'LOGIN';
my $command_line_options = join(" ",@ARGV);
GetOptions(
'help|?' => \$help,
'man' => \$man,
@ -208,7 +210,7 @@ pod2usage( -verbose => 2 ) if ($man);
pod2usage( -verbose => 2 ) if ($help and $verbose);
pod2usage(1) if $help;
cronlogaction();
cronlogaction({ info => $command_line_options });
unless ($format) {
$verbose and print STDERR "No format specified, assuming 'text'\n";
@ -359,3 +361,5 @@ foreach my $report_id (@ARGV) {
print $message;
}
}
cronlogaction({ action => 'End', info => "COMPLETED" });

View file

@ -59,6 +59,8 @@ my $verbose = 0;
my $note = '';
my $nonote = 0;
my $command_line_options = join(" ",@ARGV);
GetOptions(
'help|h|?' => \$help,
'man' => \$man,
@ -71,7 +73,7 @@ GetOptions(
pod2usage(1) if $help;
pod2usage( -verbose => 2 ) if $man;
cronlogaction();
cronlogaction({ info => $command_line_options });
$verbose and !$confirm and print "### Database will not be modified ###\n";
@ -141,3 +143,5 @@ while ( my $issue = $sth->fetchrow_hashref ) {
}
}
}
cronlogaction({ action => 'End', info => "COMPLETED" });

View file

@ -11,6 +11,8 @@ use C4::UsageStats;
use C4::Log qw( cronlogaction );
use POSIX qw( strftime );
my $command_line_options = join(" ",@ARGV);
my ( $help, $verbose, $force, $quiet );
GetOptions(
'h|help' => \$help,
@ -36,7 +38,7 @@ Setting the quiet flag will silence this message.
exit 1;
}
cronlogaction();
cronlogaction({ info => $command_line_options });
my $need_update = ($force ? 1 : C4::UsageStats::NeedUpdate() );
@ -51,6 +53,8 @@ elsif ($verbose) {
say "Data don't need to be updated";
}
cronlogaction({ action => 'End', info => "COMPLETED" });
=head1 NAME
share_usage_with_koha_community.pl - Share your library's usage with the Koha community

View file

@ -52,6 +52,8 @@ my $borrowersalreadyapplied; # hashref of borrowers for whom we already applied
my $debug = 0;
my $bigdebug = 0;
my $command_line_options = join(" ",@ARGV);
GetOptions(
'h|help' => \$help,
'v|verbose' => \$verbose,
@ -81,7 +83,7 @@ This script has the following parameters :
ENDUSAGE
die $usage if $help;
cronlogaction();
cronlogaction({ info => $command_line_options });
my $dbh = C4::Context->dbh;
@ -238,3 +240,4 @@ Number of Overdue Items:
EOM
}
cronlogaction({ action => 'End', info => "COMPLETED" });

View file

@ -52,6 +52,8 @@ my $incremental = 0;
my $commit = 100;
my $unit;
my $command_line_options = join(" ",@ARGV);
my $result = GetOptions(
'v|verbose' => \$verbose,
't|test' => \$test_only,
@ -90,7 +92,7 @@ if ( not $result or $want_help ) {
usage();
}
cronlogaction();
cronlogaction({ info => $command_line_options });
my $dbh = C4::Context->dbh;
$dbh->{AutoCommit} = 0;
@ -105,6 +107,8 @@ process_stats() if $usestats;
report();
cronlogaction({ action => 'End', info => "COMPLETED" });
exit 0;
sub process_items {