View | Details | Raw Unified | Return to bug 37869
Collapse All | Expand All

(-)a/C4/Letters.pm (-3 / +2 lines)
Lines 1027-1037 sub SendQueuedMessages { Link Here
1027
        });
1027
        });
1028
1028
1029
        if (@plugins) {
1029
        if (@plugins) {
1030
            foreach my $plugin ( @plugins ) {
1030
            foreach my $plugin (@plugins) {
1031
                try {
1031
                try {
1032
                    $plugin->before_send_messages($params);
1032
                    $plugin->before_send_messages($params);
1033
                }
1033
                } catch {
1034
                catch {
1035
                    warn "$_";
1034
                    warn "$_";
1036
                    exit 1 if $params->{exit_on_plugin_failure};
1035
                    exit 1 if $params->{exit_on_plugin_failure};
1037
                };
1036
                };
(-)a/misc/cronjobs/process_message_queue.pl (-31 / +29 lines)
Lines 21-54 use strict; Link Here
21
use warnings;
21
use warnings;
22
22
23
use Koha::Script -cron;
23
use Koha::Script -cron;
24
use C4::Letters qw( SendQueuedMessages );
24
use C4::Letters  qw( SendQueuedMessages );
25
use C4::Log qw( cronlogaction );
25
use C4::Log      qw( cronlogaction );
26
use Getopt::Long qw( GetOptions );
26
use Getopt::Long qw( GetOptions );
27
use Try::Tiny qw( catch try );
27
use Try::Tiny    qw( catch try );
28
28
29
my $username = undef;
29
my $username = undef;
30
my $password = undef;
30
my $password = undef;
31
my $limit    = undef;
31
my $limit    = undef;
32
my $method = 'LOGIN';
32
my $method   = 'LOGIN';
33
my $help = 0;
33
my $help     = 0;
34
my $verbose = 0;
34
my $verbose  = 0;
35
my $where;
35
my $where;
36
my @type;
36
my @type;
37
my @letter_code;
37
my @letter_code;
38
my $exit_on_plugin_failure = 0;
38
my $exit_on_plugin_failure = 0;
39
39
40
my $command_line_options = join(" ",@ARGV);
40
my $command_line_options = join( " ", @ARGV );
41
41
42
GetOptions(
42
GetOptions(
43
    'u|username:s'      => \$username,
43
    'u|username:s'             => \$username,
44
    'p|password:s'      => \$password,
44
    'p|password:s'             => \$password,
45
    'l|limit:s'         => \$limit,
45
    'l|limit:s'                => \$limit,
46
    'm|method:s'        => \$method,
46
    'm|method:s'               => \$method,
47
    'h|help|?'          => \$help,
47
    'h|help|?'                 => \$help,
48
    'v|verbose'         => \$verbose,
48
    'v|verbose'                => \$verbose,
49
    't|type:s'          => \@type,
49
    't|type:s'                 => \@type,
50
    'c|code:s'          => \@letter_code,
50
    'c|code:s'                 => \@letter_code,
51
    'w|where:s'         => \$where,
51
    'w|where:s'                => \$where,
52
    'e|exit-on-plugin-failure' => \$exit_on_plugin_failure,
52
    'e|exit-on-plugin-failure' => \$exit_on_plugin_failure,
53
);
53
);
54
my $usage = << 'ENDUSAGE';
54
my $usage = << 'ENDUSAGE';
Lines 74-109 ENDUSAGE Link Here
74
74
75
die $usage if $help;
75
die $usage if $help;
76
76
77
my $script_handler = Koha::Script->new({ script => $0 });
77
my $script_handler = Koha::Script->new( { script => $0 } );
78
78
79
try {
79
try {
80
    $script_handler->lock_exec;
80
    $script_handler->lock_exec;
81
}
81
} catch {
82
catch {
83
    my $message = "Skipping execution of $0 ($_)";
82
    my $message = "Skipping execution of $0 ($_)";
84
    print STDERR "$message\n"
83
    print STDERR "$message\n"
85
        if $verbose;
84
        if $verbose;
86
    cronlogaction({ info => $message });
85
    cronlogaction( { info => $message } );
87
    exit;
86
    exit;
88
};
87
};
89
88
90
cronlogaction({ info => $command_line_options });
89
cronlogaction( { info => $command_line_options } );
91
90
92
# Remove empty elements, see bug 37075
91
# Remove empty elements, see bug 37075
93
@letter_code = grep { $_ ne q{} } @letter_code;
92
@letter_code = grep { $_ ne q{} } @letter_code;
94
93
95
C4::Letters::SendQueuedMessages(
94
C4::Letters::SendQueuedMessages(
96
    {
95
    {
97
        verbose     => $verbose,
96
        verbose                => $verbose,
98
        username    => $username,
97
        username               => $username,
99
        password    => $password,
98
        password               => $password,
100
        method      => $method,
99
        method                 => $method,
101
        limit       => $limit,
100
        limit                  => $limit,
102
        type        => \@type,
101
        type                   => \@type,
103
        letter_code => \@letter_code,
102
        letter_code            => \@letter_code,
104
        where       => $where,
103
        where                  => $where,
105
        exit_on_plugin_failure => $exit_on_plugin_failure,
104
        exit_on_plugin_failure => $exit_on_plugin_failure,
106
    }
105
    }
107
);
106
);
108
107
109
cronlogaction({ action => 'End', info => "COMPLETED" });
108
cronlogaction( { action => 'End', info => "COMPLETED" } );
110
- 

Return to bug 37869