diff --git a/core/lib/Drupal/Core/Http/HandlerStackConfigurator.php b/core/lib/Drupal/Core/Http/HandlerStackConfigurator.php index d5aa3c5..b08717f 100644 --- a/core/lib/Drupal/Core/Http/HandlerStackConfigurator.php +++ b/core/lib/Drupal/Core/Http/HandlerStackConfigurator.php @@ -29,20 +29,47 @@ class HandlerStackConfigurator { * * @var callable[] */ - protected $middlewares = []; + protected $middlewares = NULL; + + /** + * A list of used middleware service IDs. + * + * @var string[] + */ + protected $middlewareIds; + + /** + * The service container. + * + * @var \Symfony\Component\DependencyInjection\ContainerInterface + */ + protected $container; /** * Contructs a new HandlerStackConfigurator object. * * @param \Symfony\Component\DependencyInjection\ContainerInterface $container * The service container. + * @param string[] $middleware_ids + * The middleware IDs. */ public function __construct(ContainerInterface $container, array $middleware_ids) { - foreach ($middleware_ids as $middleware_id) { - $middleware = $container->get($middleware_id); - if (method_exists($middleware, '__invoke')) { - $class = get_class($middleware); - $this->middlewares[$middleware_id] = $class(); + $this->middlewareIds = $middleware_ids; + $this->container = $container; + } + + /** + * Ensures that the middlewares are initialized. + */ + protected function initializeMiddlewares() { + if (!isset($this->middlewares)) { + $this->middlewares = []; + foreach ($this->middlewareIds as $middleware_id) { + $middleware = $this->container->get($middleware_id); + if (method_exists($middleware, '__invoke')) { + $class = get_class($middleware); + $this->middlewares[$middleware_id] = $class(); + } } } } @@ -54,6 +81,7 @@ public function __construct(ContainerInterface $container, array $middleware_ids * The handler stack */ public function configure(HandlerStack $handler_stack) { + $this->initializeMiddlewares(); foreach ($this->middlewares as $middleware_id => $middleware) { $handler_stack->push($middleware, $middleware_id); } diff --git a/core/modules/aggregator/src/Plugin/aggregator/fetcher/DefaultFetcher.php b/core/modules/aggregator/src/Plugin/aggregator/fetcher/DefaultFetcher.php index b7a0421..1a7870c 100644 --- a/core/modules/aggregator/src/Plugin/aggregator/fetcher/DefaultFetcher.php +++ b/core/modules/aggregator/src/Plugin/aggregator/fetcher/DefaultFetcher.php @@ -102,10 +102,10 @@ public function fetch(FeedInterface $feed) { $feed->source_string = (string) $response->getBody(); if ($response->hasHeader('ETag')) { - $feed->setEtag($response->getHeader('ETag')[0]); + $feed->setEtag($response->getHeaderLine('ETag')); } if ($response->hasHeader('Last-Modified')) { - $feed->setLastModified(strtotime($response->getHeader('Last-Modified')[0])); + $feed->setLastModified(strtotime($response->getHeaderLine('Last-Modified'))); } $feed->http_headers = $response->getHeaders(); diff --git a/core/modules/locale/locale.batch.inc b/core/modules/locale/locale.batch.inc index f549e51..42d0e8d 100644 --- a/core/modules/locale/locale.batch.inc +++ b/core/modules/locale/locale.batch.inc @@ -249,7 +249,7 @@ function locale_translation_http_check($uri) { $result['location'] = $actual_uri; } - $result['last_modified'] = $response->hasHeader('Last-Modified') ? strtotime($response->getHeader('Last-Modified')[0]) : 0; + $result['last_modified'] = $response->hasHeader('Last-Modified') ? strtotime($response->getHeaderLine('Last-Modified')) : 0; return $result; } catch (RequestException $e) {