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

(-)a/Koha/Cron.pm (+16 lines)
Line 0 Link Here
1
package Koha::Cron;
2
3
use strict;
4
use warnings;
5
use utf8;
6
use feature ':5.10';
7
8
use C4::Context;
9
10
C4::Context->_new_userenv(1);
11
C4::Context->set_userenv(
12
    '-1',  '-1',  undef, 'CRON', 'CRON', undef,
13
    undef, undef, undef, undef,  undef
14
);
15
16
1;
(-)a/misc/cronjobs/advance_notices.pl (-4 / +1 lines)
Lines 49-54 BEGIN { Link Here
49
    use FindBin;
49
    use FindBin;
50
    eval { require "$FindBin::Bin/../kohalib.pl" };
50
    eval { require "$FindBin::Bin/../kohalib.pl" };
51
}
51
}
52
use Koha::Cron;
52
use C4::Biblio;
53
use C4::Biblio;
53
use C4::Context;
54
use C4::Context;
54
use C4::Letters;
55
use C4::Letters;
Lines 223-232 END_WARN Link Here
223
unless ($confirm) {
224
unless ($confirm) {
224
     pod2usage(1);
225
     pod2usage(1);
225
}
226
}
226
C4::Context->set_userenv(
227
    '-1',  '-1',  undef, 'CRON', 'CRON', undef,
228
    undef, undef, undef, undef,  undef
229
);
230
cronlogaction();
227
cronlogaction();
231
228
232
# The fields that will be substituted into <<items.content>>
229
# The fields that will be substituted into <<items.content>>
(-)a/misc/cronjobs/automatic_item_modification_by_age.pl (-5 / +1 lines)
Lines 6-11 use Getopt::Long; Link Here
6
use Pod::Usage;
6
use Pod::Usage;
7
use JSON;
7
use JSON;
8
8
9
use Koha::Cron;
9
use C4::Context;
10
use C4::Context;
10
use C4::Items;
11
use C4::Items;
11
12
Lines 20-30 my $result = GetOptions( Link Here
20
pod2usage(1) if $help;
21
pod2usage(1) if $help;
21
$verbose = 1 unless $confirm;
22
$verbose = 1 unless $confirm;
22
23
23
C4::Context->set_userenv(
24
    '-1',  '-1',  undef, 'CRON', 'CRON', undef,
25
    undef, undef, undef, undef,  undef
26
);
27
28
# Load configuration from the syspref
24
# Load configuration from the syspref
29
my $syspref_content = C4::Context->preference('automatic_item_modification_by_age_configuration');
25
my $syspref_content = C4::Context->preference('automatic_item_modification_by_age_configuration');
30
my $rules = eval { JSON::from_json( $syspref_content ) };
26
my $rules = eval { JSON::from_json( $syspref_content ) };
(-)a/misc/cronjobs/automatic_renewals.pl (-5 / +1 lines)
Lines 52-57 use Modern::Perl; Link Here
52
use Pod::Usage;
52
use Pod::Usage;
53
use Getopt::Long;
53
use Getopt::Long;
54
54
55
use Koha::Cron;
55
use C4::Circulation;
56
use C4::Circulation;
56
use C4::Context;
57
use C4::Context;
57
use C4::Log;
58
use C4::Log;
Lines 67-77 GetOptions( Link Here
67
) || pod2usage(1);
68
) || pod2usage(1);
68
69
69
pod2usage(0) if $help;
70
pod2usage(0) if $help;
70
71
C4::Context->set_userenv(
72
    '-1',  '-1',  undef, 'CRON', 'CRON', undef,
73
    undef, undef, undef, undef,  undef
74
);
75
cronlogaction();
71
cronlogaction();
76
72
77
my $auto_renews = Koha::Checkouts->search({ auto_renew => 1 });
73
my $auto_renews = Koha::Checkouts->search({ auto_renew => 1 });
(-)a/misc/cronjobs/batch_anonymise.pl (-4 / +1 lines)
Lines 29-34 BEGIN { Link Here
29
    eval { require "$FindBin::Bin/../kohalib.pl" };
29
    eval { require "$FindBin::Bin/../kohalib.pl" };
30
}
30
}
31
31
32
use Koha::Cron;
32
use C4::Context;
33
use C4::Context;
33
use Koha::Patrons;
34
use Koha::Patrons;
34
use Date::Calc qw(
35
use Date::Calc qw(
Lines 67-76 if ( !$days ) { Link Here
67
    usage(1);
68
    usage(1);
68
}
69
}
69
70
70
C4::Context->set_userenv(
71
    '-1',  '-1',  undef, 'CRON', 'CRON', undef,
72
    undef, undef, undef, undef,  undef
73
);
74
cronlogaction();
71
cronlogaction();
75
72
76
my ($year,$month,$day) = Today();
73
my ($year,$month,$day) = Today();
(-)a/misc/cronjobs/build_browser_and_cloud.pl (-4 / +1 lines)
Lines 10-15 BEGIN { Link Here
10
    eval { require "$FindBin::Bin/../kohalib.pl" };
10
    eval { require "$FindBin::Bin/../kohalib.pl" };
11
}
11
}
12
12
13
use Koha::Cron;
13
use C4::Koha;
14
use C4::Koha;
14
use C4::Context;
15
use C4::Context;
15
use C4::Biblio;
16
use C4::Biblio;
Lines 62-71 my $browser_subfield = $2; Link Here
62
warn "browser : $browser_tag / $browser_subfield" unless $batch;
63
warn "browser : $browser_tag / $browser_subfield" unless $batch;
63
die "no cloud or browser field/subfield defined : nothing to do !" unless $browser_tag or $cloud_tag;
64
die "no cloud or browser field/subfield defined : nothing to do !" unless $browser_tag or $cloud_tag;
64
65
65
C4::Context->set_userenv(
66
    '-1',  '-1',  undef, 'CRON', 'CRON', undef,
67
    undef, undef, undef, undef,  undef
68
);
69
cronlogaction();
66
cronlogaction();
70
67
71
my $dbh = C4::Context->dbh;
68
my $dbh = C4::Context->dbh;
(-)a/misc/cronjobs/cart_to_shelf.pl (-4 / +1 lines)
Lines 28-33 cart_to_shelf.pl cron script to set items with location of CART to original she Link Here
28
use strict;
28
use strict;
29
use warnings;
29
use warnings;
30
30
31
use Koha::Cron;
31
use C4::Items qw/ CartToShelf /;
32
use C4::Items qw/ CartToShelf /;
32
use C4::Log;
33
use C4::Log;
33
34
Lines 64-73 unless ($hours) { Link Here
64
    die "ERROR: No --hours (-h) option defined";
65
    die "ERROR: No --hours (-h) option defined";
65
}
66
}
66
67
67
C4::Context->set_userenv(
68
    '-1',  '-1',  undef, 'CRON', 'CRON', undef,
69
    undef, undef, undef, undef,  undef
70
);
71
cronlogaction();
68
cronlogaction();
72
69
73
my $query = "SELECT itemnumber FROM items WHERE location = 'CART' AND TIMESTAMPDIFF(HOUR, items.timestamp, NOW() ) > ?";
70
my $query = "SELECT itemnumber FROM items WHERE location = 'CART' AND TIMESTAMPDIFF(HOUR, items.timestamp, NOW() ) > ?";
(-)a/misc/cronjobs/check-url-quick.pl (-5 / +2 lines)
Lines 20-25 Link Here
20
use Modern::Perl;
20
use Modern::Perl;
21
use Pod::Usage;
21
use Pod::Usage;
22
use Getopt::Long;
22
use Getopt::Long;
23
24
use Koha::Cron;
23
use C4::Context;
25
use C4::Context;
24
use C4::Biblio;
26
use C4::Biblio;
25
use AnyEvent;
27
use AnyEvent;
Lines 43-53 GetOptions( Link Here
43
    'tags=s{,}'       => \@tags,
45
    'tags=s{,}'       => \@tags,
44
);
46
);
45
47
46
C4::Context->set_userenv(
47
    '-1',  '-1',  undef, 'CRON', 'CRON', undef,
48
    undef, undef, undef, undef,  undef
49
);
50
51
# Validate tags to check
48
# Validate tags to check
52
{
49
{
53
    my %h = map { $_ => undef } @tags;
50
    my %h = map { $_ => undef } @tags;
(-)a/misc/cronjobs/check-url.pl (+2 lines)
Lines 78-83 use strict; Link Here
78
use warnings;
78
use warnings;
79
use LWP::UserAgent;
79
use LWP::UserAgent;
80
use HTTP::Request;
80
use HTTP::Request;
81
use Koha::Cron;
81
use C4::Biblio;
82
use C4::Biblio;
82
83
83
84
Lines 147-152 use Carp; Link Here
147
148
148
use Pod::Usage;
149
use Pod::Usage;
149
use Getopt::Long;
150
use Getopt::Long;
151
use Koha::Cron;
150
use C4::Context;
152
use C4::Context;
151
153
152
154
(-)a/misc/cronjobs/cleanup_database.pl (-4 / +1 lines)
Lines 34-39 BEGIN { Link Here
34
    eval { require "$FindBin::Bin/../kohalib.pl" };
34
    eval { require "$FindBin::Bin/../kohalib.pl" };
35
}
35
}
36
36
37
use Koha::Cron;
37
use C4::Context;
38
use C4::Context;
38
use C4::Search;
39
use C4::Search;
39
use C4::Search::History;
40
use C4::Search::History;
Lines 176-185 if ($pDebarments && $allDebarments) { Link Here
176
    usage(1);
177
    usage(1);
177
}
178
}
178
179
179
C4::Context->set_userenv(
180
    '-1',  '-1',  undef, 'CRON', 'CRON', undef,
181
    undef, undef, undef, undef,  undef
182
);
183
cronlogaction();
180
cronlogaction();
184
181
185
my $dbh = C4::Context->dbh();
182
my $dbh = C4::Context->dbh();
(-)a/misc/cronjobs/cloud-kw.pl (-4 / +2 lines)
Lines 25-30 use Carp; Link Here
25
use YAML::Syck;
25
use YAML::Syck;
26
use Pod::Usage;
26
use Pod::Usage;
27
use Getopt::Long;
27
use Getopt::Long;
28
29
use Koha::Cron;
28
use C4::Context;
30
use C4::Context;
29
use C4::Log;
31
use C4::Log;
30
32
Lines 44-53 sub usage { Link Here
44
46
45
usage() if $help || !$conf;
47
usage() if $help || !$conf;
46
48
47
C4::Context->set_userenv(
48
    '-1',  '-1',  undef, 'CRON', 'CRON', undef,
49
    undef, undef, undef, undef,  undef
50
);
51
cronlogaction();
49
cronlogaction();
52
50
53
my @clouds;
51
my @clouds;
(-)a/misc/cronjobs/create_koc_db.pl (-5 / +2 lines)
Lines 94-99 $|++; Link Here
94
use DBI;
94
use DBI;
95
use Getopt::Long;
95
use Getopt::Long;
96
use Pod::Usage;
96
use Pod::Usage;
97
98
use Koha::Cron;
97
use C4::Context;
99
use C4::Context;
98
use English qw(-no_match_vars);
100
use English qw(-no_match_vars);
99
101
Lines 118-128 GetOptions( Link Here
118
pod2usage(1) if $help;
120
pod2usage(1) if $help;
119
pod2usage( -verbose => 2 ) if $man;
121
pod2usage( -verbose => 2 ) if $man;
120
122
121
C4::Context->set_userenv(
122
    '-1',  '-1',  undef, 'CRON', 'CRON', undef,
123
    undef, undef, undef, undef,  undef
124
);
125
126
my %wanted_borrowers_columns = map { $_ => 1 } qw/borrowernumber cardnumber surname  firstname address city phone dateofbirth/; 
123
my %wanted_borrowers_columns = map { $_ => 1 } qw/borrowernumber cardnumber surname  firstname address city phone dateofbirth/; 
127
my %wanted_issues_columns    = map { $_ => 1 } qw/borrowernumber date_due itemcallnumber title itemtype/;
124
my %wanted_issues_columns    = map { $_ => 1 } qw/borrowernumber date_due itemcallnumber title itemtype/;
128
125
(-)a/misc/cronjobs/delete_expired_opac_registrations.pl (+1 lines)
Lines 28-33 BEGIN { Link Here
28
    eval { my $lib = "$FindBin::Bin/../kohalib.pl"; require $lib };
28
    eval { my $lib = "$FindBin::Bin/../kohalib.pl"; require $lib };
29
}
29
}
30
30
31
use Koha::Cron;
31
use C4::Context;
32
use C4::Context;
32
33
33
my $help;
34
my $help;
(-)a/misc/cronjobs/delete_items.pl (-5 / +2 lines)
Lines 1-17 Link Here
1
#! /usr/bin/perl
1
#! /usr/bin/perl
2
2
3
use Getopt::Long;
3
use Getopt::Long;
4
5
use Koha::Cron;
4
use C4::Context;
6
use C4::Context;
5
use C4::Items;
7
use C4::Items;
6
use C4::Circulation;
8
use C4::Circulation;
7
use Modern::Perl;
9
use Modern::Perl;
8
use Pod::Usage;
10
use Pod::Usage;
9
11
10
C4::Context->set_userenv(
11
    '-1',  '-1',  undef, 'CRON', 'CRON', undef,
12
    undef, undef, undef, undef,  undef
13
);
14
15
my $dbh = C4::Context->dbh();
12
my $dbh = C4::Context->dbh();
16
13
17
my $query = {
14
my $query = {
(-)a/misc/cronjobs/delete_patrons.pl (-4 / +1 lines)
Lines 5-10 use Modern::Perl; Link Here
5
use Pod::Usage;
5
use Pod::Usage;
6
use Getopt::Long;
6
use Getopt::Long;
7
7
8
use Koha::Cron;
8
use C4::Members;
9
use C4::Members;
9
use Koha::DateUtils;
10
use Koha::DateUtils;
10
use Koha::Patrons;
11
use Koha::Patrons;
Lines 41-50 unless ( $not_borrowed_since or $expired_before or $last_seen or $category_code Link Here
41
    pod2usage(q{At least one filter is mandatory});
42
    pod2usage(q{At least one filter is mandatory});
42
}
43
}
43
44
44
C4::Context->set_userenv(
45
    '-1',  '-1',  undef, 'CRON', 'CRON', undef,
46
    undef, undef, undef, undef,  undef
47
);
48
cronlogaction();
45
cronlogaction();
49
46
50
my $members = GetBorrowersToExpunge(
47
my $members = GetBorrowersToExpunge(
(-)a/misc/cronjobs/delete_records_via_leader.pl (-5 / +1 lines)
Lines 33-38 BEGIN { Link Here
33
33
34
use Getopt::Long;
34
use Getopt::Long;
35
use Pod::Usage;
35
use Pod::Usage;
36
use Koha::Cron;
36
use C4::Biblio;
37
use C4::Biblio;
37
use C4::Items;
38
use C4::Items;
38
use Koha::Database;
39
use Koha::Database;
Lines 77-87 This script has the following parameters : Link Here
77
    exit();
78
    exit();
78
}
79
}
79
80
80
C4::Context->set_userenv(
81
    '-1',  '-1',  undef, 'CRON', 'CRON', undef,
82
    undef, undef, undef, undef,  undef
83
);
84
85
my @metadatas =    # Should be replaced by a call to C4::Search on zebra index
81
my @metadatas =    # Should be replaced by a call to C4::Search on zebra index
86
                   # Record-status when bug 15537 will be pushed
82
                   # Record-status when bug 15537 will be pushed
87
  Koha::Biblio::Metadatas->search( { format => 'marcxml', schema => C4::Context->preference('marcflavour'), metadata => { LIKE => '%<leader>_____d%' } } );
83
  Koha::Biblio::Metadatas->search( { format => 'marcxml', schema => C4::Context->preference('marcflavour'), metadata => { LIKE => '%<leader>_____d%' } } );
(-)a/misc/cronjobs/edi_cron.pl (-5 / +1 lines)
Lines 29-34 use utf8; Link Here
29
# can be run as frequently as required
29
# can be run as frequently as required
30
# log messages are appended to logdir/editrace.log
30
# log messages are appended to logdir/editrace.log
31
31
32
use Koha::Cron;
32
use C4::Context;
33
use C4::Context;
33
use Log::Log4perl qw(:easy);
34
use Log::Log4perl qw(:easy);
34
use Koha::Database;
35
use Koha::Database;
Lines 36-46 use Koha::EDI qw( process_quote process_invoice process_ordrsp); Link Here
36
use Koha::Edifact::Transport;
37
use Koha::Edifact::Transport;
37
use Fcntl qw( :DEFAULT :flock :seek );
38
use Fcntl qw( :DEFAULT :flock :seek );
38
39
39
C4::Context->set_userenv(
40
    '-1',  '-1',  undef, 'CRON', 'CRON', undef,
41
    undef, undef, undef, undef,  undef
42
);
43
44
my $logdir = C4::Context->config('logdir');
40
my $logdir = C4::Context->config('logdir');
45
41
46
# logging set to trace as this may be what you
42
# logging set to trace as this may be what you
(-)a/misc/cronjobs/fines.pl (-4 / +1 lines)
Lines 30-35 use strict; Link Here
30
use warnings;
30
use warnings;
31
use 5.010;
31
use 5.010;
32
32
33
use Koha::Cron;
33
use C4::Context;
34
use C4::Context;
34
use C4::Overdues;
35
use C4::Overdues;
35
use Getopt::Long;
36
use Getopt::Long;
Lines 71-80 if ($help) { Link Here
71
    exit;
72
    exit;
72
}
73
}
73
74
74
C4::Context->set_userenv(
75
    '-1',  '-1',  undef, 'CRON', 'CRON', undef,
76
    undef, undef, undef, undef,  undef
77
);
78
cronlogaction();
75
cronlogaction();
79
76
80
my @borrower_fields =
77
my @borrower_fields =
(-)a/misc/cronjobs/gather_print_notices.pl (-4 / +1 lines)
Lines 10-15 BEGIN { Link Here
10
}
10
}
11
11
12
use CGI qw( utf8 ); # NOT a CGI script, this is just to keep C4::Templates::gettemplate happy
12
use CGI qw( utf8 ); # NOT a CGI script, this is just to keep C4::Templates::gettemplate happy
13
use Koha::Cron;
13
use C4::Context;
14
use C4::Context;
14
use C4::Debug;
15
use C4::Debug;
15
use C4::Letters;
16
use C4::Letters;
Lines 79-88 if ( $ods and @letter_codes != 1 ) { Link Here
79
80
80
$delimiter ||= q|,|;
81
$delimiter ||= q|,|;
81
82
82
C4::Context->set_userenv(
83
    '-1',  '-1',  undef, 'CRON', 'CRON', undef,
84
    undef, undef, undef, undef,  undef
85
);
86
cronlogaction();
83
cronlogaction();
87
84
88
my $today_iso     = output_pref( { dt => dt_from_string, dateonly => 1, dateformat => 'iso' } ) ;
85
my $today_iso     = output_pref( { dt => dt_from_string, dateonly => 1, dateformat => 'iso' } ) ;
(-)a/misc/cronjobs/holds/auto_unsuspend_holds.pl (-4 / +1 lines)
Lines 29-41 BEGIN { Link Here
29
29
30
# cancel all expired hold requests
30
# cancel all expired hold requests
31
31
32
use Koha::Cron;
32
use C4::Reserves;
33
use C4::Reserves;
33
use C4::Log;
34
use C4::Log;
34
35
35
C4::Context->set_userenv(
36
    '-1',  '-1',  undef, 'CRON', 'CRON', undef,
37
    undef, undef, undef, undef,  undef
38
);
39
cronlogaction();
36
cronlogaction();
40
37
41
AutoUnsuspendReserves();
38
AutoUnsuspendReserves();
(-)a/misc/cronjobs/holds/build_holds_queue.pl (-4 / +1 lines)
Lines 15-27 BEGIN { Link Here
15
    eval { require "$FindBin::Bin/../kohalib.pl" };
15
    eval { require "$FindBin::Bin/../kohalib.pl" };
16
}
16
}
17
17
18
use Koha::Cron;
18
use C4::HoldsQueue qw(CreateQueue);
19
use C4::HoldsQueue qw(CreateQueue);
19
use C4::Log;
20
use C4::Log;
20
21
21
C4::Context->set_userenv(
22
    '-1',  '-1',  undef, 'CRON', 'CRON', undef,
23
    undef, undef, undef, undef,  undef
24
);
25
cronlogaction();
22
cronlogaction();
26
23
27
CreateQueue();
24
CreateQueue();
(-)a/misc/cronjobs/holds/cancel_expired_holds.pl (-4 / +1 lines)
Lines 29-41 BEGIN { Link Here
29
29
30
# cancel all expired hold requests
30
# cancel all expired hold requests
31
31
32
use Koha::Cron;
32
use C4::Reserves;
33
use C4::Reserves;
33
use C4::Log;
34
use C4::Log;
34
35
35
C4::Context->set_userenv(
36
    '-1',  '-1',  undef, 'CRON', 'CRON', undef,
37
    undef, undef, undef, undef,  undef
38
);
39
cronlogaction();
36
cronlogaction();
40
37
41
CancelExpiredReserves();
38
CancelExpiredReserves();
(-)a/misc/cronjobs/holds/cancel_unfilled_holds.pl (-4 / +1 lines)
Lines 28-33 BEGIN { Link Here
28
use Getopt::Long;
28
use Getopt::Long;
29
use Pod::Usage;
29
use Pod::Usage;
30
30
31
use Koha::Cron;
31
use C4::Reserves;
32
use C4::Reserves;
32
use C4::Log;
33
use C4::Log;
33
use Koha::Holds;
34
use Koha::Holds;
Lines 35-44 use Koha::Calendar; Link Here
35
use Koha::DateUtils;
36
use Koha::DateUtils;
36
use Koha::Libraries;
37
use Koha::Libraries;
37
38
38
C4::Context->set_userenv(
39
    '-1',  '-1',  undef, 'CRON', 'CRON', undef,
40
    undef, undef, undef, undef,  undef
41
);
42
cronlogaction();
39
cronlogaction();
43
40
44
=head1 NAME
41
=head1 NAME
(-)a/misc/cronjobs/import_webservice_batch.pl (-4 / +1 lines)
Lines 31-36 BEGIN { Link Here
31
31
32
use Getopt::Long;
32
use Getopt::Long;
33
use Pod::Usage;
33
use Pod::Usage;
34
use Koha::Cron;
34
use C4::ImportBatch;
35
use C4::ImportBatch;
35
36
36
my ($help, $framework);
37
my ($help, $framework);
Lines 50-59 EOF Link Here
50
;
51
;
51
    exit;
52
    exit;
52
}
53
}
53
C4::Context->set_userenv(
54
    '-1',  '-1',  undef, 'CRON', 'CRON', undef,
55
    undef, undef, undef, undef,  undef
56
);
57
54
58
my $batch_ids = GetStagedWebserviceBatches() or exit;
55
my $batch_ids = GetStagedWebserviceBatches() or exit;
59
56
(-)a/misc/cronjobs/j2a.pl (-4 / +1 lines)
Lines 26-31 BEGIN { Link Here
26
    eval { require "$FindBin::Bin/../kohalib.pl" };
26
    eval { require "$FindBin::Bin/../kohalib.pl" };
27
}
27
}
28
28
29
use Koha::Cron;
29
use C4::Context;
30
use C4::Context;
30
use C4::Members;
31
use C4::Members;
31
use Getopt::Long;
32
use Getopt::Long;
Lines 125-134 if ( not $fromcat && $tocat ) { #make sure we've specified the info we need. Link Here
125
    exit;
126
    exit;
126
}
127
}
127
128
128
C4::Context->set_userenv(
129
    '-1',  '-1',  undef, 'CRON', 'CRON', undef,
130
    undef, undef, undef, undef,  undef
131
);
132
cronlogaction();
129
cronlogaction();
133
130
134
my $dbh = C4::Context->dbh;
131
my $dbh = C4::Context->dbh;
(-)a/misc/cronjobs/longoverdue.pl (-4 / +2 lines)
Lines 33-38 BEGIN { Link Here
33
    use FindBin;
33
    use FindBin;
34
    eval { require "$FindBin::Bin/../kohalib.pl" };
34
    eval { require "$FindBin::Bin/../kohalib.pl" };
35
}
35
}
36
37
use Koha::Cron;
36
use C4::Context;
38
use C4::Context;
37
use C4::Items;
39
use C4::Items;
38
use C4::Circulation qw/LostItem MarkIssueReturned/;
40
use C4::Circulation qw/LostItem MarkIssueReturned/;
Lines 228-237 unless ($confirm) { Link Here
228
    print "### TEST MODE -- NO ACTIONS TAKEN ###\n";
230
    print "### TEST MODE -- NO ACTIONS TAKEN ###\n";
229
}
231
}
230
232
231
C4::Context->set_userenv(
232
    '-1',  '-1',  undef, 'CRON', 'CRON', undef,
233
    undef, undef, undef, undef,  undef
234
);
235
cronlogaction();
233
cronlogaction();
236
234
237
# In my opinion, this line is safe SQL to have outside the API. --atz
235
# In my opinion, this line is safe SQL to have outside the API. --atz
(-)a/misc/cronjobs/membership_expiry.pl (-4 / +1 lines)
Lines 126-131 BEGIN { Link Here
126
    eval { require "$FindBin::Bin/../kohalib.pl" };
126
    eval { require "$FindBin::Bin/../kohalib.pl" };
127
}
127
}
128
128
129
use Koha::Cron;
129
use C4::Context;
130
use C4::Context;
130
use C4::Letters;
131
use C4::Letters;
131
use C4::Log;
132
use C4::Log;
Lines 157-166 GetOptions( Link Here
157
pod2usage( -verbose => 2 ) if $man;
158
pod2usage( -verbose => 2 ) if $man;
158
pod2usage(1) if $help || !$confirm;
159
pod2usage(1) if $help || !$confirm;
159
160
160
C4::Context->set_userenv(
161
    '-1',  '-1',  undef, 'CRON', 'CRON', undef,
162
    undef, undef, undef, undef,  undef
163
);
164
cronlogaction();
161
cronlogaction();
165
162
166
my $expdays = C4::Context->preference('MembershipExpiryDaysNotice');
163
my $expdays = C4::Context->preference('MembershipExpiryDaysNotice');
(-)a/misc/cronjobs/merge_authorities.pl (-4 / +1 lines)
Lines 5-10 use Getopt::Long; Link Here
5
use Pod::Usage;
5
use Pod::Usage;
6
use Time::HiRes qw(gettimeofday);
6
use Time::HiRes qw(gettimeofday);
7
7
8
use Koha::Cron;
8
use C4::AuthoritiesMarc;
9
use C4::AuthoritiesMarc;
9
use Koha::Authority::MergeRequests;
10
use Koha::Authority::MergeRequests;
10
11
Lines 20-29 GetOptions( Link Here
20
21
21
$|=1; # flushes output
22
$|=1; # flushes output
22
if ( $params->{batch} ) {
23
if ( $params->{batch} ) {
23
    C4::Context->set_userenv(
24
        '-1',  '-1',  undef, 'CRON', 'CRON', undef,
25
        undef, undef, undef, undef,  undef
26
    );
27
    handle_batch($params);
24
    handle_batch($params);
28
}
25
}
29
else {
26
else {
(-)a/misc/cronjobs/notice_unprocessed_suggestions.pl (-5 / +1 lines)
Lines 5-10 use Modern::Perl; Link Here
5
use Pod::Usage;
5
use Pod::Usage;
6
use Getopt::Long;
6
use Getopt::Long;
7
7
8
use Koha::Cron;
8
use C4::Budgets qw( GetBudget );
9
use C4::Budgets qw( GetBudget );
9
use C4::Suggestions qw( GetUnprocessedSuggestions );
10
use C4::Suggestions qw( GetUnprocessedSuggestions );
10
use Koha::Libraries;
11
use Koha::Libraries;
Lines 22-32 if ($help) { Link Here
22
    pod2usage( verbose => 2 );
23
    pod2usage( verbose => 2 );
23
}
24
}
24
25
25
C4::Context->set_userenv(
26
    '-1',  '-1',  undef, 'CRON', 'CRON', undef,
27
    undef, undef, undef, undef,  undef
28
);
29
30
unless (@days) {
26
unless (@days) {
31
    pod2usage(q{At least one day parameter should be given});
27
    pod2usage(q{At least one day parameter should be given});
32
    exit;
28
    exit;
(-)a/misc/cronjobs/overdue_notices.pl (-5 / +1 lines)
Lines 34-39 use Text::CSV_XS; Link Here
34
use DateTime;
34
use DateTime;
35
use DateTime::Duration;
35
use DateTime::Duration;
36
36
37
use Koha::Cron;
37
use C4::Context;
38
use C4::Context;
38
use C4::Letters;
39
use C4::Letters;
39
use C4::Overdues qw(GetFine GetOverdueMessageTransportTypes parse_overdues_letter);
40
use C4::Overdues qw(GetFine GetOverdueMessageTransportTypes parse_overdues_letter);
Lines 325-335 GetOptions( Link Here
325
) or pod2usage(2);
326
) or pod2usage(2);
326
pod2usage(1) if $help;
327
pod2usage(1) if $help;
327
pod2usage( -verbose => 2 ) if $man;
328
pod2usage( -verbose => 2 ) if $man;
328
329
C4::Context->set_userenv(
330
    '-1',  '-1',  undef, 'CRON', 'CRON', undef,
331
    undef, undef, undef, undef,  undef
332
);
333
cronlogaction() unless $test_mode;
329
cronlogaction() unless $test_mode;
334
330
335
if ( defined $csvfilename && $csvfilename =~ /^-/ ) {
331
if ( defined $csvfilename && $csvfilename =~ /^-/ ) {
(-)a/misc/cronjobs/process_message_queue.pl (-4 / +2 lines)
Lines 25-30 BEGIN { Link Here
25
    use FindBin;
25
    use FindBin;
26
    eval { require "$FindBin::Bin/../kohalib.pl" };
26
    eval { require "$FindBin::Bin/../kohalib.pl" };
27
}
27
}
28
29
use Koha::Cron;
28
use C4::Letters;
30
use C4::Letters;
29
use C4::Log;
31
use C4::Log;
30
use Getopt::Long;
32
use Getopt::Long;
Lines 66-75 ENDUSAGE Link Here
66
68
67
die $usage if $help;
69
die $usage if $help;
68
70
69
C4::Context->set_userenv(
70
    '-1',  '-1',  undef, 'CRON', 'CRON', undef,
71
    undef, undef, undef, undef,  undef
72
);
73
cronlogaction();
71
cronlogaction();
74
72
75
C4::Letters::SendQueuedMessages(
73
C4::Letters::SendQueuedMessages(
(-)a/misc/cronjobs/purge_suggestions.pl (-4 / +2 lines)
Lines 28-33 BEGIN { Link Here
28
28
29
use Getopt::Long;
29
use Getopt::Long;
30
use Pod::Usage;
30
use Pod::Usage;
31
32
use Koha::Cron;
31
use C4::Suggestions;
33
use C4::Suggestions;
32
use C4::Log;
34
use C4::Log;
33
use C4::Context;
35
use C4::Context;
Lines 63-72 if( !$confirm || $help || !defined($days) ) { Link Here
63
    print "No confirm parameter passed!\n\n" if !$confirm && !$help;
65
    print "No confirm parameter passed!\n\n" if !$confirm && !$help;
64
    print $usage;
66
    print $usage;
65
} elsif( $days and $days > 0 ) {
67
} elsif( $days and $days > 0 ) {
66
    C4::Context->set_userenv(
67
        '-1',  '-1',  undef, 'CRON', 'CRON', undef,
68
        undef, undef, undef, undef,  undef
69
    );
70
    cronlogaction( " ( days: $days )");
68
    cronlogaction( " ( days: $days )");
71
    DelSuggestionsOlderThan($days);
69
    DelSuggestionsOlderThan($days);
72
} else {
70
} else {
(-)a/misc/cronjobs/reconcile_balances.pl (-4 / +1 lines)
Lines 62-67 BEGIN { Link Here
62
    eval { require "$FindBin::Bin/../kohalib.pl" };
62
    eval { require "$FindBin::Bin/../kohalib.pl" };
63
}
63
}
64
64
65
use Koha::Cron;
65
use C4::Log;
66
use C4::Log;
66
67
67
use Koha::Account::Lines;
68
use Koha::Account::Lines;
Lines 76-85 GetOptions( Link Here
76
) or pod2usage(2);
77
) or pod2usage(2);
77
78
78
pod2usage(1) if $help;
79
pod2usage(1) if $help;
79
C4::Context->set_userenv(
80
    '-1',  '-1',  undef, 'CRON', 'CRON', undef,
81
    undef, undef, undef, undef,  undef
82
);
83
cronlogaction();
80
cronlogaction();
84
81
85
my @patron_ids = map { $_->borrowernumber } Koha::Account::Lines->search(
82
my @patron_ids = map { $_->borrowernumber } Koha::Account::Lines->search(
(-)a/misc/cronjobs/remove_temporary_edifiles.pl (+1 lines)
Lines 2-7 Link Here
2
use strict;
2
use strict;
3
use warnings;
3
use warnings;
4
4
5
use Koha::Cron;
5
use C4::Context;
6
use C4::Context;
6
7
7
# this script will remove those older than 5 days
8
# this script will remove those older than 5 days
(-)a/misc/cronjobs/runreport.pl (-4 / +1 lines)
Lines 20-25 Link Here
20
20
21
use Modern::Perl;
21
use Modern::Perl;
22
22
23
use Koha::Cron;
23
use C4::Reports::Guided; # 0.12
24
use C4::Reports::Guided; # 0.12
24
use Koha::Reports;
25
use Koha::Reports;
25
use C4::Context;
26
use C4::Context;
Lines 204-213 pod2usage( -verbose => 2 ) if ($man); Link Here
204
pod2usage( -verbose => 2 ) if ($help and $verbose);
205
pod2usage( -verbose => 2 ) if ($help and $verbose);
205
pod2usage(1) if $help;
206
pod2usage(1) if $help;
206
207
207
C4::Context->set_userenv(
208
    '-1',  '-1',  undef, 'CRON', 'CRON', undef,
209
    undef, undef, undef, undef,  undef
210
);
211
cronlogaction();
208
cronlogaction();
212
209
213
unless ($format) {
210
unless ($format) {
(-)a/misc/cronjobs/serialsUpdate.pl (-4 / +1 lines)
Lines 28-33 BEGIN { Link Here
28
    eval { require "$FindBin::Bin/../kohalib.pl" };
28
    eval { require "$FindBin::Bin/../kohalib.pl" };
29
}
29
}
30
30
31
use Koha::Cron;
31
use C4::Context;
32
use C4::Context;
32
use C4::Debug;
33
use C4::Debug;
33
use C4::Serials;
34
use C4::Serials;
Lines 79-88 GetOptions( Link Here
79
pod2usage(1) if $help;
80
pod2usage(1) if $help;
80
pod2usage( -verbose => 2 ) if $man;
81
pod2usage( -verbose => 2 ) if $man;
81
82
82
C4::Context->set_userenv(
83
    '-1',  '-1',  undef, 'CRON', 'CRON', undef,
84
    undef, undef, undef, undef,  undef
85
);
86
cronlogaction();
83
cronlogaction();
87
84
88
$verbose and !$confirm and print "### Database will not be modified ###\n";
85
$verbose and !$confirm and print "### Database will not be modified ###\n";
(-)a/misc/cronjobs/share_usage_with_koha_community.pl (-4 / +1 lines)
Lines 5-10 use Modern::Perl; Link Here
5
use Pod::Usage;
5
use Pod::Usage;
6
use Getopt::Long;
6
use Getopt::Long;
7
7
8
use Koha::Cron;
8
use C4::Context;
9
use C4::Context;
9
use C4::UsageStats;
10
use C4::UsageStats;
10
use C4::Log;
11
use C4::Log;
Lines 35-44 Setting the quiet flag will silence this message. Link Here
35
    exit 1;
36
    exit 1;
36
}
37
}
37
38
38
C4::Context->set_userenv(
39
    '-1',  '-1',  undef, 'CRON', 'CRON', undef,
40
    undef, undef, undef, undef,  undef
41
);
42
cronlogaction();
39
cronlogaction();
43
40
44
my $need_update = ($force ? 1 : C4::UsageStats::NeedUpdate() );
41
my $need_update = ($force ? 1 : C4::UsageStats::NeedUpdate() );
(-)a/misc/cronjobs/sitemap.pl (+2 lines)
Lines 23-28 use Modern::Perl; Link Here
23
use utf8;
23
use utf8;
24
use Pod::Usage;
24
use Pod::Usage;
25
use Getopt::Long;
25
use Getopt::Long;
26
27
use Koha::Cron;
26
use C4::Biblio;
28
use C4::Biblio;
27
use Koha::Sitemapper;
29
use Koha::Sitemapper;
28
30
(-)a/misc/cronjobs/staticfines.pl (-4 / +1 lines)
Lines 37-42 BEGIN { Link Here
37
37
38
use Date::Calc qw/Date_to_Days/;
38
use Date::Calc qw/Date_to_Days/;
39
39
40
use Koha::Cron;
40
use C4::Context;
41
use C4::Context;
41
use C4::Circulation;
42
use C4::Circulation;
42
use C4::Overdues;
43
use C4::Overdues;
Lines 91-100 This script has the following parameters : Link Here
91
ENDUSAGE
92
ENDUSAGE
92
die $usage if $help;
93
die $usage if $help;
93
94
94
C4::Context->set_userenv(
95
    '-1',  '-1',  undef, 'CRON', 'CRON', undef,
96
    undef, undef, undef, undef,  undef
97
);
98
cronlogaction();
95
cronlogaction();
99
96
100
my $dbh = C4::Context->dbh;
97
my $dbh = C4::Context->dbh;
(-)a/misc/cronjobs/stockrotation.pl (-5 / +2 lines)
Lines 109-123 database updates have been performed."). Link Here
109
109
110
use Modern::Perl;
110
use Modern::Perl;
111
use Getopt::Long qw/HelpMessage :config gnu_getopt/;
111
use Getopt::Long qw/HelpMessage :config gnu_getopt/;
112
113
use Koha::Cron;
112
use C4::Context;
114
use C4::Context;
113
use C4::Letters;
115
use C4::Letters;
114
use Koha::StockRotationRotas;
116
use Koha::StockRotationRotas;
115
117
116
C4::Context->set_userenv(
117
    '-1',  '-1',  undef, 'CRON', 'CRON', undef,
118
    undef, undef, undef, undef,  undef
119
);
120
121
my $admin_email = '';
118
my $admin_email = '';
122
my $branch      = 0;
119
my $branch      = 0;
123
my $execute     = 0;
120
my $execute     = 0;
(-)a/misc/cronjobs/update_totalissues.pl (-5 / +2 lines)
Lines 30-35 BEGIN { Link Here
30
30
31
use Getopt::Long;
31
use Getopt::Long;
32
use Pod::Usage;
32
use Pod::Usage;
33
34
use Koha::Cron;
33
use C4::Context;
35
use C4::Context;
34
use C4::Biblio;
36
use C4::Biblio;
35
use C4::Log;
37
use C4::Log;
Lines 95-104 if ( not $result or $want_help ) { Link Here
95
    usage();
97
    usage();
96
}
98
}
97
99
98
C4::Context->set_userenv(
99
    '-1',  '-1',  undef, 'CRON', 'CRON', undef,
100
    undef, undef, undef, undef,  undef
101
);
102
cronlogaction();
100
cronlogaction();
103
101
104
my $dbh = C4::Context->dbh;
102
my $dbh = C4::Context->dbh;
105
- 

Return to bug 22577