public function Cron::run in Zircon Profile 8
Same name in this branch
- 8 core/lib/Drupal/Core/Cron.php \Drupal\Core\Cron::run()
- 8 core/lib/Drupal/Core/ProxyClass/Cron.php \Drupal\Core\ProxyClass\Cron::run()
Same name and namespace in other branches
- 8.0 core/lib/Drupal/Core/Cron.php \Drupal\Core\Cron::run()
Executes a cron run.
Do not call this function from a test. Use $this->cronRun() instead.
Return value
bool TRUE upon success, FALSE otherwise.
Overrides CronInterface::run
File
- core/
lib/ Drupal/ Core/ Cron.php, line 105 - Contains \Drupal\Core\Cron.
Class
- Cron
- The Drupal core Cron service.
Namespace
Drupal\CoreCode
public function run() {
// Allow execution to continue even if the request gets cancelled.
@ignore_user_abort(TRUE);
// Force the current user to anonymous to ensure consistent permissions on
// cron runs.
$this->accountSwitcher
->switchTo(new AnonymousUserSession());
// Try to allocate enough time to run all the hook_cron implementations.
drupal_set_time_limit(240);
$return = FALSE;
// Try to acquire cron lock.
if (!$this->lock
->acquire('cron', 900.0)) {
// Cron is still running normally.
$this->logger
->warning('Attempting to re-run cron while it is already running.');
}
else {
$this
->invokeCronHandlers();
$this
->setCronLastTime();
// Release cron lock.
$this->lock
->release('cron');
// Return TRUE so other functions can check if it did run successfully
$return = TRUE;
}
// Process cron queues.
$this
->processQueues();
// Restore the user.
$this->accountSwitcher
->switchBack();
return $return;
}