Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(cron): Ignore time sensitivity when a class was explicitely scheduled #50942

Merged
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 7 additions & 5 deletions cron.php
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@

Arguments:
job-classes Optional job class list to only run those jobs
Providing a class will ignore the time-sensitivity restriction

Options:
-h, --help Display this help message
Expand Down Expand Up @@ -112,10 +113,14 @@
$appConfig->setValueString('core', 'backgroundjobs_mode', 'cron');
}

// a specific job class list can optionally be given as argument
$jobClasses = array_slice($argv, $verbose ? 2 : 1);
$jobClasses = empty($jobClasses) ? null : $jobClasses;

// Low-load hours
$onlyTimeSensitive = false;
$startHour = $config->getSystemValueInt('maintenance_window_start', 100);
if ($startHour <= 23) {
if ($jobClasses === null && $startHour <= 23) {
$date = new \DateTime('now', new \DateTimeZone('UTC'));
$currentHour = (int)$date->format('G');
$endHour = $startHour + 4;
Expand Down Expand Up @@ -143,9 +148,6 @@
$endTime = time() + 14 * 60;

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

while ($job = $jobList->getNext($onlyTimeSensitive, $jobClasses)) {
if (isset($executedJobs[$job->getId()])) {
Expand All @@ -159,7 +161,7 @@
$timeBefore = time();
$memoryBefore = memory_get_usage();
$memoryPeakBefore = memory_get_peak_usage();

if ($verbose) {
echo 'Starting job ' . $jobDetails . PHP_EOL;
}
Expand Down
Loading