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

(-)a/misc/cronjobs/advance_notices.pl (-1 / +4 lines)
Lines 223-229 END_WARN Link Here
223
unless ($confirm) {
223
unless ($confirm) {
224
     pod2usage(1);
224
     pod2usage(1);
225
}
225
}
226
226
C4::Context->set_userenv(
227
    '-1',  '-1',  undef, 'CRON', 'CRON', undef,
228
    undef, undef, undef, undef,  undef
229
);
227
cronlogaction();
230
cronlogaction();
228
231
229
# The fields that will be substituted into <<items.content>>
232
# The fields that will be substituted into <<items.content>>
(-)a/misc/cronjobs/automatic_item_modification_by_age.pl (+5 lines)
Lines 20-25 my $result = GetOptions( Link Here
20
pod2usage(1) if $help;
20
pod2usage(1) if $help;
21
$verbose = 1 unless $confirm;
21
$verbose = 1 unless $confirm;
22
22
23
C4::Context->set_userenv(
24
    '-1',  '-1',  undef, 'CRON', 'CRON', undef,
25
    undef, undef, undef, undef,  undef
26
);
27
23
# Load configuration from the syspref
28
# Load configuration from the syspref
24
my $syspref_content = C4::Context->preference('automatic_item_modification_by_age_configuration');
29
my $syspref_content = C4::Context->preference('automatic_item_modification_by_age_configuration');
25
my $rules = eval { JSON::from_json( $syspref_content ) };
30
my $rules = eval { JSON::from_json( $syspref_content ) };
(-)a/misc/cronjobs/automatic_renewals.pl (+4 lines)
Lines 68-73 GetOptions( Link Here
68
68
69
pod2usage(0) if $help;
69
pod2usage(0) if $help;
70
70
71
C4::Context->set_userenv(
72
    '-1',  '-1',  undef, 'CRON', 'CRON', undef,
73
    undef, undef, undef, undef,  undef
74
);
71
cronlogaction();
75
cronlogaction();
72
76
73
my $auto_renews = Koha::Checkouts->search({ auto_renew => 1 });
77
my $auto_renews = Koha::Checkouts->search({ auto_renew => 1 });
(-)a/misc/cronjobs/batch_anonymise.pl (+4 lines)
Lines 67-72 if ( !$days ) { Link Here
67
    usage(1);
67
    usage(1);
68
}
68
}
69
69
70
C4::Context->set_userenv(
71
    '-1',  '-1',  undef, 'CRON', 'CRON', undef,
72
    undef, undef, undef, undef,  undef
73
);
70
cronlogaction();
74
cronlogaction();
71
75
72
my ($year,$month,$day) = Today();
76
my ($year,$month,$day) = Today();
(-)a/misc/cronjobs/build_browser_and_cloud.pl (+4 lines)
Lines 62-67 my $browser_subfield = $2; Link Here
62
warn "browser : $browser_tag / $browser_subfield" unless $batch;
62
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;
63
die "no cloud or browser field/subfield defined : nothing to do !" unless $browser_tag or $cloud_tag;
64
64
65
C4::Context->set_userenv(
66
    '-1',  '-1',  undef, 'CRON', 'CRON', undef,
67
    undef, undef, undef, undef,  undef
68
);
65
cronlogaction();
69
cronlogaction();
66
70
67
my $dbh = C4::Context->dbh;
71
my $dbh = C4::Context->dbh;
(-)a/misc/cronjobs/cart_to_shelf.pl (+4 lines)
Lines 64-69 unless ($hours) { Link Here
64
    die "ERROR: No --hours (-h) option defined";
64
    die "ERROR: No --hours (-h) option defined";
65
}
65
}
66
66
67
C4::Context->set_userenv(
68
    '-1',  '-1',  undef, 'CRON', 'CRON', undef,
69
    undef, undef, undef, undef,  undef
70
);
67
cronlogaction();
71
cronlogaction();
68
72
69
my $query = "SELECT itemnumber FROM items WHERE location = 'CART' AND TIMESTAMPDIFF(HOUR, items.timestamp, NOW() ) > ?";
73
my $query = "SELECT itemnumber FROM items WHERE location = 'CART' AND TIMESTAMPDIFF(HOUR, items.timestamp, NOW() ) > ?";
(-)a/misc/cronjobs/check-url-quick.pl (+5 lines)
Lines 43-48 GetOptions( Link Here
43
    'tags=s{,}'       => \@tags,
43
    'tags=s{,}'       => \@tags,
44
);
44
);
45
45
46
C4::Context->set_userenv(
47
    '-1',  '-1',  undef, 'CRON', 'CRON', undef,
48
    undef, undef, undef, undef,  undef
49
);
50
46
# Validate tags to check
51
# Validate tags to check
47
{
52
{
48
    my %h = map { $_ => undef } @tags;
53
    my %h = map { $_ => undef } @tags;
(-)a/misc/cronjobs/cleanup_database.pl (+4 lines)
Lines 176-181 if ($pDebarments && $allDebarments) { Link Here
176
    usage(1);
176
    usage(1);
177
}
177
}
178
178
179
C4::Context->set_userenv(
180
    '-1',  '-1',  undef, 'CRON', 'CRON', undef,
181
    undef, undef, undef, undef,  undef
182
);
179
cronlogaction();
183
cronlogaction();
180
184
181
my $dbh = C4::Context->dbh();
185
my $dbh = C4::Context->dbh();
(-)a/misc/cronjobs/cloud-kw.pl (-1 / +5 lines)
Lines 42-49 sub usage { Link Here
42
    exit;
42
    exit;
43
} 
43
} 
44
44
45
usage() if $help || !$conf;          
45
usage() if $help || !$conf;
46
46
47
C4::Context->set_userenv(
48
    '-1',  '-1',  undef, 'CRON', 'CRON', undef,
49
    undef, undef, undef, undef,  undef
50
);
47
cronlogaction();
51
cronlogaction();
48
52
49
my @clouds;
53
my @clouds;
(-)a/misc/cronjobs/create_koc_db.pl (+4 lines)
Lines 118-123 GetOptions( Link Here
118
pod2usage(1) if $help;
118
pod2usage(1) if $help;
119
pod2usage( -verbose => 2 ) if $man;
119
pod2usage( -verbose => 2 ) if $man;
120
120
121
C4::Context->set_userenv(
122
    '-1',  '-1',  undef, 'CRON', 'CRON', undef,
123
    undef, undef, undef, undef,  undef
124
);
121
125
122
my %wanted_borrowers_columns = map { $_ => 1 } qw/borrowernumber cardnumber surname  firstname address city phone dateofbirth/; 
126
my %wanted_borrowers_columns = map { $_ => 1 } qw/borrowernumber cardnumber surname  firstname address city phone dateofbirth/; 
123
my %wanted_issues_columns    = map { $_ => 1 } qw/borrowernumber date_due itemcallnumber title itemtype/;
127
my %wanted_issues_columns    = map { $_ => 1 } qw/borrowernumber date_due itemcallnumber title itemtype/;
(-)a/misc/cronjobs/delete_items.pl (+5 lines)
Lines 7-12 use C4::Circulation; Link Here
7
use Modern::Perl;
7
use Modern::Perl;
8
use Pod::Usage;
8
use Pod::Usage;
9
9
10
C4::Context->set_userenv(
11
    '-1',  '-1',  undef, 'CRON', 'CRON', undef,
12
    undef, undef, undef, undef,  undef
13
);
14
10
my $dbh = C4::Context->dbh();
15
my $dbh = C4::Context->dbh();
11
16
12
my $query = {
17
my $query = {
(-)a/misc/cronjobs/delete_patrons.pl (+4 lines)
Lines 41-46 unless ( $not_borrowed_since or $expired_before or $last_seen or $category_code Link Here
41
    pod2usage(q{At least one filter is mandatory});
41
    pod2usage(q{At least one filter is mandatory});
42
}
42
}
43
43
44
C4::Context->set_userenv(
45
    '-1',  '-1',  undef, 'CRON', 'CRON', undef,
46
    undef, undef, undef, undef,  undef
47
);
44
cronlogaction();
48
cronlogaction();
45
49
46
my $members = GetBorrowersToExpunge(
50
my $members = GetBorrowersToExpunge(
(-)a/misc/cronjobs/delete_records_via_leader.pl (+5 lines)
Lines 77-82 This script has the following parameters : Link Here
77
    exit();
77
    exit();
78
}
78
}
79
79
80
C4::Context->set_userenv(
81
    '-1',  '-1',  undef, 'CRON', 'CRON', undef,
82
    undef, undef, undef, undef,  undef
83
);
84
80
my @metadatas =    # Should be replaced by a call to C4::Search on zebra index
85
my @metadatas =    # Should be replaced by a call to C4::Search on zebra index
81
                   # Record-status when bug 15537 will be pushed
86
                   # Record-status when bug 15537 will be pushed
82
  Koha::Biblio::Metadatas->search( { format => 'marcxml', schema => C4::Context->preference('marcflavour'), metadata => { LIKE => '%<leader>_____d%' } } );
87
  Koha::Biblio::Metadatas->search( { format => 'marcxml', schema => C4::Context->preference('marcflavour'), metadata => { LIKE => '%<leader>_____d%' } } );
(-)a/misc/cronjobs/edi_cron.pl (+5 lines)
Lines 36-41 use Koha::EDI qw( process_quote process_invoice process_ordrsp); Link Here
36
use Koha::Edifact::Transport;
36
use Koha::Edifact::Transport;
37
use Fcntl qw( :DEFAULT :flock :seek );
37
use Fcntl qw( :DEFAULT :flock :seek );
38
38
39
C4::Context->set_userenv(
40
    '-1',  '-1',  undef, 'CRON', 'CRON', undef,
41
    undef, undef, undef, undef,  undef
42
);
43
39
my $logdir = C4::Context->config('logdir');
44
my $logdir = C4::Context->config('logdir');
40
45
41
# logging set to trace as this may be what you
46
# logging set to trace as this may be what you
(-)a/misc/cronjobs/gather_print_notices.pl (+4 lines)
Lines 79-84 if ( $ods and @letter_codes != 1 ) { Link Here
79
79
80
$delimiter ||= q|,|;
80
$delimiter ||= q|,|;
81
81
82
C4::Context->set_userenv(
83
    '-1',  '-1',  undef, 'CRON', 'CRON', undef,
84
    undef, undef, undef, undef,  undef
85
);
82
cronlogaction();
86
cronlogaction();
83
87
84
my $today_iso     = output_pref( { dt => dt_from_string, dateonly => 1, dateformat => 'iso' } ) ;
88
my $today_iso     = output_pref( { dt => dt_from_string, dateonly => 1, dateformat => 'iso' } ) ;
(-)a/misc/cronjobs/holds/auto_unsuspend_holds.pl (+4 lines)
Lines 32-37 BEGIN { Link Here
32
use C4::Reserves;
32
use C4::Reserves;
33
use C4::Log;
33
use C4::Log;
34
34
35
C4::Context->set_userenv(
36
    '-1',  '-1',  undef, 'CRON', 'CRON', undef,
37
    undef, undef, undef, undef,  undef
38
);
35
cronlogaction();
39
cronlogaction();
36
40
37
AutoUnsuspendReserves();
41
AutoUnsuspendReserves();
(-)a/misc/cronjobs/holds/build_holds_queue.pl (+4 lines)
Lines 18-23 BEGIN { Link Here
18
use C4::HoldsQueue qw(CreateQueue);
18
use C4::HoldsQueue qw(CreateQueue);
19
use C4::Log;
19
use C4::Log;
20
20
21
C4::Context->set_userenv(
22
    '-1',  '-1',  undef, 'CRON', 'CRON', undef,
23
    undef, undef, undef, undef,  undef
24
);
21
cronlogaction();
25
cronlogaction();
22
26
23
CreateQueue();
27
CreateQueue();
(-)a/misc/cronjobs/holds/cancel_expired_holds.pl (+4 lines)
Lines 32-37 BEGIN { Link Here
32
use C4::Reserves;
32
use C4::Reserves;
33
use C4::Log;
33
use C4::Log;
34
34
35
C4::Context->set_userenv(
36
    '-1',  '-1',  undef, 'CRON', 'CRON', undef,
37
    undef, undef, undef, undef,  undef
38
);
35
cronlogaction();
39
cronlogaction();
36
40
37
CancelExpiredReserves();
41
CancelExpiredReserves();
(-)a/misc/cronjobs/holds/cancel_unfilled_holds.pl (+4 lines)
Lines 35-40 use Koha::Calendar; Link Here
35
use Koha::DateUtils;
35
use Koha::DateUtils;
36
use Koha::Libraries;
36
use Koha::Libraries;
37
37
38
C4::Context->set_userenv(
39
    '-1',  '-1',  undef, 'CRON', 'CRON', undef,
40
    undef, undef, undef, undef,  undef
41
);
38
cronlogaction();
42
cronlogaction();
39
43
40
=head1 NAME
44
=head1 NAME
(-)a/misc/cronjobs/import_webservice_batch.pl (+4 lines)
Lines 50-55 EOF Link Here
50
;
50
;
51
    exit;
51
    exit;
52
}
52
}
53
C4::Context->set_userenv(
54
    '-1',  '-1',  undef, 'CRON', 'CRON', undef,
55
    undef, undef, undef, undef,  undef
56
);
53
57
54
my $batch_ids = GetStagedWebserviceBatches() or exit;
58
my $batch_ids = GetStagedWebserviceBatches() or exit;
55
59
(-)a/misc/cronjobs/j2a.pl (+4 lines)
Lines 125-130 if ( not $fromcat && $tocat ) { #make sure we've specified the info we need. Link Here
125
    exit;
125
    exit;
126
}
126
}
127
127
128
C4::Context->set_userenv(
129
    '-1',  '-1',  undef, 'CRON', 'CRON', undef,
130
    undef, undef, undef, undef,  undef
131
);
128
cronlogaction();
132
cronlogaction();
129
133
130
my $dbh = C4::Context->dbh;
134
my $dbh = C4::Context->dbh;
(-)a/misc/cronjobs/longoverdue.pl (+4 lines)
Lines 228-233 unless ($confirm) { Link Here
228
    print "### TEST MODE -- NO ACTIONS TAKEN ###\n";
228
    print "### TEST MODE -- NO ACTIONS TAKEN ###\n";
229
}
229
}
230
230
231
C4::Context->set_userenv(
232
    '-1',  '-1',  undef, 'CRON', 'CRON', undef,
233
    undef, undef, undef, undef,  undef
234
);
231
cronlogaction();
235
cronlogaction();
232
236
233
# In my opinion, this line is safe SQL to have outside the API. --atz
237
# In my opinion, this line is safe SQL to have outside the API. --atz
(-)a/misc/cronjobs/membership_expiry.pl (+4 lines)
Lines 157-162 GetOptions( Link Here
157
pod2usage( -verbose => 2 ) if $man;
157
pod2usage( -verbose => 2 ) if $man;
158
pod2usage(1) if $help || !$confirm;
158
pod2usage(1) if $help || !$confirm;
159
159
160
C4::Context->set_userenv(
161
    '-1',  '-1',  undef, 'CRON', 'CRON', undef,
162
    undef, undef, undef, undef,  undef
163
);
160
cronlogaction();
164
cronlogaction();
161
165
162
my $expdays = C4::Context->preference('MembershipExpiryDaysNotice');
166
my $expdays = C4::Context->preference('MembershipExpiryDaysNotice');
(-)a/misc/cronjobs/merge_authorities.pl (-3 / +8 lines)
Lines 19-27 GetOptions( Link Here
19
);
19
);
20
20
21
$|=1; # flushes output
21
$|=1; # flushes output
22
if( $params->{batch} ) {
22
if ( $params->{batch} ) {
23
    handle_batch( $params );
23
    C4::Context->set_userenv(
24
} else {
24
        '-1',  '-1',  undef, 'CRON', 'CRON', undef,
25
        undef, undef, undef, undef,  undef
26
    );
27
    handle_batch($params);
28
}
29
else {
25
    pod2usage(1);
30
    pod2usage(1);
26
}
31
}
27
32
(-)a/misc/cronjobs/notice_unprocessed_suggestions.pl (+5 lines)
Lines 22-27 if ($help) { Link Here
22
    pod2usage( verbose => 2 );
22
    pod2usage( verbose => 2 );
23
}
23
}
24
24
25
C4::Context->set_userenv(
26
    '-1',  '-1',  undef, 'CRON', 'CRON', undef,
27
    undef, undef, undef, undef,  undef
28
);
29
25
unless (@days) {
30
unless (@days) {
26
    pod2usage(q{At least one day parameter should be given});
31
    pod2usage(q{At least one day parameter should be given});
27
    exit;
32
    exit;
(-)a/misc/cronjobs/overdue_notices.pl (+4 lines)
Lines 326-331 GetOptions( Link Here
326
pod2usage(1) if $help;
326
pod2usage(1) if $help;
327
pod2usage( -verbose => 2 ) if $man;
327
pod2usage( -verbose => 2 ) if $man;
328
328
329
C4::Context->set_userenv(
330
    '-1',  '-1',  undef, 'CRON', 'CRON', undef,
331
    undef, undef, undef, undef,  undef
332
);
329
cronlogaction() unless $test_mode;
333
cronlogaction() unless $test_mode;
330
334
331
if ( defined $csvfilename && $csvfilename =~ /^-/ ) {
335
if ( defined $csvfilename && $csvfilename =~ /^-/ ) {
(-)a/misc/cronjobs/process_message_queue.pl (+4 lines)
Lines 66-71 ENDUSAGE Link Here
66
66
67
die $usage if $help;
67
die $usage if $help;
68
68
69
C4::Context->set_userenv(
70
    '-1',  '-1',  undef, 'CRON', 'CRON', undef,
71
    undef, undef, undef, undef,  undef
72
);
69
cronlogaction();
73
cronlogaction();
70
74
71
C4::Letters::SendQueuedMessages(
75
C4::Letters::SendQueuedMessages(
(-)a/misc/cronjobs/purge_suggestions.pl (+4 lines)
Lines 63-68 if( !$confirm || $help || !defined($days) ) { Link Here
63
    print "No confirm parameter passed!\n\n" if !$confirm && !$help;
63
    print "No confirm parameter passed!\n\n" if !$confirm && !$help;
64
    print $usage;
64
    print $usage;
65
} elsif( $days and $days > 0 ) {
65
} elsif( $days and $days > 0 ) {
66
    C4::Context->set_userenv(
67
        '-1',  '-1',  undef, 'CRON', 'CRON', undef,
68
        undef, undef, undef, undef,  undef
69
    );
66
    cronlogaction( " ( days: $days )");
70
    cronlogaction( " ( days: $days )");
67
    DelSuggestionsOlderThan($days);
71
    DelSuggestionsOlderThan($days);
68
} else {
72
} else {
(-)a/misc/cronjobs/reconcile_balances.pl (-1 / +4 lines)
Lines 76-82 GetOptions( Link Here
76
) or pod2usage(2);
76
) or pod2usage(2);
77
77
78
pod2usage(1) if $help;
78
pod2usage(1) if $help;
79
79
C4::Context->set_userenv(
80
    '-1',  '-1',  undef, 'CRON', 'CRON', undef,
81
    undef, undef, undef, undef,  undef
82
);
80
cronlogaction();
83
cronlogaction();
81
84
82
my @patron_ids = map { $_->borrowernumber } Koha::Account::Lines->search(
85
my @patron_ids = map { $_->borrowernumber } Koha::Account::Lines->search(
(-)a/misc/cronjobs/runreport.pl (+4 lines)
Lines 204-209 pod2usage( -verbose => 2 ) if ($man); Link Here
204
pod2usage( -verbose => 2 ) if ($help and $verbose);
204
pod2usage( -verbose => 2 ) if ($help and $verbose);
205
pod2usage(1) if $help;
205
pod2usage(1) if $help;
206
206
207
C4::Context->set_userenv(
208
    '-1',  '-1',  undef, 'CRON', 'CRON', undef,
209
    undef, undef, undef, undef,  undef
210
);
207
cronlogaction();
211
cronlogaction();
208
212
209
unless ($format) {
213
unless ($format) {
(-)a/misc/cronjobs/serialsUpdate.pl (+4 lines)
Lines 79-84 GetOptions( Link Here
79
pod2usage(1) if $help;
79
pod2usage(1) if $help;
80
pod2usage( -verbose => 2 ) if $man;
80
pod2usage( -verbose => 2 ) if $man;
81
81
82
C4::Context->set_userenv(
83
    '-1',  '-1',  undef, 'CRON', 'CRON', undef,
84
    undef, undef, undef, undef,  undef
85
);
82
cronlogaction();
86
cronlogaction();
83
87
84
$verbose and !$confirm and print "### Database will not be modified ###\n";
88
$verbose and !$confirm and print "### Database will not be modified ###\n";
(-)a/misc/cronjobs/share_usage_with_koha_community.pl (+4 lines)
Lines 35-40 Setting the quiet flag will silence this message. Link Here
35
    exit 1;
35
    exit 1;
36
}
36
}
37
37
38
C4::Context->set_userenv(
39
    '-1',  '-1',  undef, 'CRON', 'CRON', undef,
40
    undef, undef, undef, undef,  undef
41
);
38
cronlogaction();
42
cronlogaction();
39
43
40
my $need_update = ($force ? 1 : C4::UsageStats::NeedUpdate() );
44
my $need_update = ($force ? 1 : C4::UsageStats::NeedUpdate() );
(-)a/misc/cronjobs/staticfines.pl (+4 lines)
Lines 91-96 This script has the following parameters : Link Here
91
ENDUSAGE
91
ENDUSAGE
92
die $usage if $help;
92
die $usage if $help;
93
93
94
C4::Context->set_userenv(
95
    '-1',  '-1',  undef, 'CRON', 'CRON', undef,
96
    undef, undef, undef, undef,  undef
97
);
94
cronlogaction();
98
cronlogaction();
95
99
96
my $dbh = C4::Context->dbh;
100
my $dbh = C4::Context->dbh;
(-)a/misc/cronjobs/stockrotation.pl (+5 lines)
Lines 113-118 use C4::Context; Link Here
113
use C4::Letters;
113
use C4::Letters;
114
use Koha::StockRotationRotas;
114
use Koha::StockRotationRotas;
115
115
116
C4::Context->set_userenv(
117
    '-1',  '-1',  undef, 'CRON', 'CRON', undef,
118
    undef, undef, undef, undef,  undef
119
);
120
116
my $admin_email = '';
121
my $admin_email = '';
117
my $branch      = 0;
122
my $branch      = 0;
118
my $execute     = 0;
123
my $execute     = 0;
(-)a/misc/cronjobs/thirdparty/TalkingTech_itiva_outbound.pl (+5 lines)
Lines 89-94 $library_code ||= ''; Link Here
89
89
90
pod2usage( -verbose => 1 ) if $help;
90
pod2usage( -verbose => 1 ) if $help;
91
91
92
C4::Context->set_userenv(
93
    '-1',  '-1',  undef, 'CRON', 'CRON', undef,
94
    undef, undef, undef, undef,  undef
95
);
96
92
# output log or STDOUT
97
# output log or STDOUT
93
my $OUT;
98
my $OUT;
94
if ( defined $outfile ) {
99
if ( defined $outfile ) {
(-)a/misc/cronjobs/update_totalissues.pl (-1 / +4 lines)
Lines 95-100 if ( not $result or $want_help ) { Link Here
95
    usage();
95
    usage();
96
}
96
}
97
97
98
C4::Context->set_userenv(
99
    '-1',  '-1',  undef, 'CRON', 'CRON', undef,
100
    undef, undef, undef, undef,  undef
101
);
98
cronlogaction();
102
cronlogaction();
99
103
100
my $dbh = C4::Context->dbh;
104
my $dbh = C4::Context->dbh;
101
- 

Return to bug 22577