Skip to content

Commit 72e3e13

Browse files
committed
fix(cron): Ignore time sensitivity when a class was explicitely scheduled
Signed-off-by: Joas Schilling <[email protected]>
1 parent 33a12eb commit 72e3e13

File tree

1 file changed

+7
-5
lines changed

1 file changed

+7
-5
lines changed

cron.php

+7-5
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,7 @@
3232
3333
Arguments:
3434
job-classes Optional job class list to only run those jobs
35+
Providing a class will ignore the time-sensitivity restriction
3536
3637
Options:
3738
-h, --help Display this help message
@@ -112,10 +113,14 @@
112113
$appConfig->setValueString('core', 'backgroundjobs_mode', 'cron');
113114
}
114115

116+
// a specific job class list can optionally be given as argument
117+
$jobClasses = array_slice($argv, $verbose ? 2 : 1);
118+
$jobClasses = empty($jobClasses) ? null : $jobClasses;
119+
115120
// Low-load hours
116121
$onlyTimeSensitive = false;
117122
$startHour = $config->getSystemValueInt('maintenance_window_start', 100);
118-
if ($startHour <= 23) {
123+
if ($jobClasses === null && $startHour <= 23) {
119124
$date = new \DateTime('now', new \DateTimeZone('UTC'));
120125
$currentHour = (int)$date->format('G');
121126
$endHour = $startHour + 4;
@@ -143,9 +148,6 @@
143148
$endTime = time() + 14 * 60;
144149

145150
$executedJobs = [];
146-
// a specific job class list can optionally be given as argument
147-
$jobClasses = array_slice($argv, $verbose ? 2 : 1);
148-
$jobClasses = empty($jobClasses) ? null : $jobClasses;
149151

150152
while ($job = $jobList->getNext($onlyTimeSensitive, $jobClasses)) {
151153
if (isset($executedJobs[$job->getId()])) {
@@ -159,7 +161,7 @@
159161
$timeBefore = time();
160162
$memoryBefore = memory_get_usage();
161163
$memoryPeakBefore = memory_get_peak_usage();
162-
164+
163165
if ($verbose) {
164166
echo 'Starting job ' . $jobDetails . PHP_EOL;
165167
}

0 commit comments

Comments
 (0)