diff --git a/core/modules/system/system.module b/core/modules/system/system.module index 709fd1f..a7ba3a4 100644 --- a/core/modules/system/system.module +++ b/core/modules/system/system.module @@ -8,8 +8,8 @@ use Drupal\Core\Utility\ModuleInfo; use Drupal\Core\TypedData\Primitive; +use Guzzle\Plugin\Async\AsyncPlugin; use Symfony\Component\HttpFoundation\JsonResponse; -use Symfony\Component\HttpFoundation\Response; /** * Maximum age of temporary files in seconds. @@ -3686,7 +3686,18 @@ function system_run_automated_cron() { if (($threshold = config('system.cron')->get('threshold.autorun')) > 0 && variable_get('install_task') == 'done') { $cron_last = state()->get('system.cron_last') ?: NULL; if (!isset($cron_last) || (REQUEST_TIME - $cron_last > $threshold)) { - drupal_cron_run(); + // Only execute the request if we can aquire the lock. If this fails then + // another request is already taking care of it and we don't have to + // retry. + if (lock()->acquire('cron_request')) { + // Execute the asynchronous request. This will return immediately with a + // HTTP/1.1 200 OK and X-Guzzle-Async as the singe header. + $url = url('cron/' . state()->get('system.cron_key'), array('absolute' => TRUE)); + $request = drupal_container()->get('http_default_client')->get($url); + $request->addSubscriber(new AsyncPlugin()); + $request->send(); + lock()->release('cron_request'); + } } } }