Merge pull request #50954 from nextcloud/backport/50942/stable31

[stable31] fix(cron): Ignore time sensitivity when a class was explicitely scheduled
This commit is contained in:
Joas Schilling 2025-02-25 14:05:30 +01:00 committed by GitHub
commit 63b9a48e69
No known key found for this signature in database
GPG key ID: B5690EEEBB952194

View file

@ -32,6 +32,7 @@ Usage:
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
@ -112,10 +113,14 @@ Options:
$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;
@ -143,9 +148,6 @@ Options:
$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()])) {
@ -159,7 +161,7 @@ Options:
$timeBefore = time();
$memoryBefore = memory_get_usage();
$memoryPeakBefore = memory_get_peak_usage();
if ($verbose) {
echo 'Starting job ' . $jobDetails . PHP_EOL;
}