From 9c75f67560eb1723268b54ff9107c0161f28a612 Mon Sep 17 00:00:00 2001 From: Kyle M Hall Date: Mon, 9 Sep 2024 10:32:52 -0400 Subject: [PATCH] Bug 37869: Tidy code Signed-off-by: David Nind Signed-off-by: Martin Renvoize Signed-off-by: Katrin Fischer --- C4/Letters.pm | 5 +-- misc/cronjobs/process_message_queue.pl | 59 +++++++++++++------------- 2 files changed, 31 insertions(+), 33 deletions(-) diff --git a/C4/Letters.pm b/C4/Letters.pm index 4fb28fdcce..ce8ffda7e1 100644 --- a/C4/Letters.pm +++ b/C4/Letters.pm @@ -1027,11 +1027,10 @@ sub SendQueuedMessages { }); if (@plugins) { - foreach my $plugin ( @plugins ) { + foreach my $plugin (@plugins) { try { $plugin->before_send_messages($params); - } - catch { + } catch { warn "$_"; exit 1 if $params->{exit_on_plugin_failure}; }; diff --git a/misc/cronjobs/process_message_queue.pl b/misc/cronjobs/process_message_queue.pl index 031b965fe4..ebaa7230f0 100755 --- a/misc/cronjobs/process_message_queue.pl +++ b/misc/cronjobs/process_message_queue.pl @@ -21,34 +21,34 @@ use strict; use warnings; use Koha::Script -cron; -use C4::Letters qw( SendQueuedMessages ); -use C4::Log qw( cronlogaction ); +use C4::Letters qw( SendQueuedMessages ); +use C4::Log qw( cronlogaction ); use Getopt::Long qw( GetOptions ); -use Try::Tiny qw( catch try ); +use Try::Tiny qw( catch try ); my $username = undef; my $password = undef; my $limit = undef; -my $method = 'LOGIN'; -my $help = 0; -my $verbose = 0; +my $method = 'LOGIN'; +my $help = 0; +my $verbose = 0; my $where; my @type; my @letter_code; my $exit_on_plugin_failure = 0; -my $command_line_options = join(" ",@ARGV); +my $command_line_options = join( " ", @ARGV ); GetOptions( - 'u|username:s' => \$username, - 'p|password:s' => \$password, - 'l|limit:s' => \$limit, - 'm|method:s' => \$method, - 'h|help|?' => \$help, - 'v|verbose' => \$verbose, - 't|type:s' => \@type, - 'c|code:s' => \@letter_code, - 'w|where:s' => \$where, + 'u|username:s' => \$username, + 'p|password:s' => \$password, + 'l|limit:s' => \$limit, + 'm|method:s' => \$method, + 'h|help|?' => \$help, + 'v|verbose' => \$verbose, + 't|type:s' => \@type, + 'c|code:s' => \@letter_code, + 'w|where:s' => \$where, 'e|exit-on-plugin-failure' => \$exit_on_plugin_failure, ); my $usage = << 'ENDUSAGE'; @@ -74,36 +74,35 @@ ENDUSAGE die $usage if $help; -my $script_handler = Koha::Script->new({ script => $0 }); +my $script_handler = Koha::Script->new( { script => $0 } ); try { $script_handler->lock_exec; -} -catch { +} catch { my $message = "Skipping execution of $0 ($_)"; print STDERR "$message\n" if $verbose; - cronlogaction({ info => $message }); + cronlogaction( { info => $message } ); exit; }; -cronlogaction({ info => $command_line_options }); +cronlogaction( { info => $command_line_options } ); # Remove empty elements, see bug 37075 @letter_code = grep { $_ ne q{} } @letter_code; C4::Letters::SendQueuedMessages( { - verbose => $verbose, - username => $username, - password => $password, - method => $method, - limit => $limit, - type => \@type, - letter_code => \@letter_code, - where => $where, + verbose => $verbose, + username => $username, + password => $password, + method => $method, + limit => $limit, + type => \@type, + letter_code => \@letter_code, + where => $where, exit_on_plugin_failure => $exit_on_plugin_failure, } ); -cronlogaction({ action => 'End', info => "COMPLETED" }); +cronlogaction( { action => 'End', info => "COMPLETED" } ); -- 2.39.5