diff --git a/core/modules/automated_cron/src/EventSubscriber/AutomatedCron.php b/core/modules/automated_cron/src/EventSubscriber/AutomatedCron.php index 6eed009..de5e365 100644 --- a/core/modules/automated_cron/src/EventSubscriber/AutomatedCron.php +++ b/core/modules/automated_cron/src/EventSubscriber/AutomatedCron.php @@ -82,21 +82,34 @@ public function onTerminate(PostResponseEvent $event) { // \GuzzleHttp\Promise\PromiseInterface object, which can be either // fulfilled or rejected. $url = Url::fromRoute('system.cron', ['key' => $this->state->get('system.cron_key')], ['absolute' => TRUE])->toString(); - $promise = $this->httpClient->requestAsync('GET', $url); - - // Since the lock is persistent between requests, we have to release - // it no matter if the promise is fulfilled (cron succeeded) or - // rejected (cron failed), otherwise we will never be able to acquire - // it again in the future. - $promise->then( - function () { $this->lock->release('cron_request'); }, - function () { $this->lock->release('cron_request'); } - ); + + try { + $this->doAsyncRequset($url); + } + catch (\Exception $e) { + watchdog_exception('automated_cron', $e); + } + finally { + $this->lock->release('cron_request'); + } } } } } + protected function doAsyncRequset($url) { + $parts = parse_url($url); + + $fp = fsockopen($parts['host'], isset($parts['port']) ? $parts['port'] : 80, $errno, $errstr, 30); + + $out = 'POST ' . $parts['path'] . " HTTP/1.1\r\n"; + $out .= 'Host: ' . $parts['host'] . "\r\n"; + $out .= "Connection: Close\r\n\r\n"; + + fwrite($fp, $out); + fclose($fp); + } + /** * Registers the methods in this class that should be listeners. *