diff --git a/core/lib/Drupal/Core/DependencyInjection/Container.php b/core/lib/Drupal/Core/DependencyInjection/Container.php index 4ac3c65..516d1c2 100644 --- a/core/lib/Drupal/Core/DependencyInjection/Container.php +++ b/core/lib/Drupal/Core/DependencyInjection/Container.php @@ -7,7 +7,6 @@ namespace Drupal\Core\DependencyInjection; -use \ReflectionClass; use Symfony\Component\DependencyInjection\ContainerInterface; use Symfony\Component\DependencyInjection\IntrospectableContainerInterface; use Symfony\Component\DependencyInjection\ScopeInterface; @@ -215,7 +214,7 @@ public function get($id, $invalidBehavior = ContainerInterface::EXCEPTION_ON_INV * @return object * The service described by the service definition. * - * @throws Symfony\Component\DependencyInjection\Exception\RuntimeException\RuntimeExceptio + * @throws Symfony\Component\DependencyInjection\Exception\RuntimeException\RuntimeException * Thrown when the service is a synthetic service. * @throws Symfony\Component\DependencyInjection\Exception\InvalidArgumentException * Thrown when the configurator callable is not callable. @@ -291,7 +290,7 @@ protected function createService($definition, $id) { $service = new $class($arguments[0], $arguments[1], $arguments[2], $arguments[3], $arguments[4], $arguments[5], $arguments[6], $arguments[7], $arguments[8], $arguments[9]); break; default: - $r = new ReflectionClass($class); + $r = new \ReflectionClass($class); $service = $r->newInstanceArgs($arguments); break; } diff --git a/core/lib/Drupal/Core/DependencyInjection/Dumper/OptimizedPhpArrayDumper.php b/core/lib/Drupal/Core/DependencyInjection/Dumper/OptimizedPhpArrayDumper.php index 998c208..df9fccd 100644 --- a/core/lib/Drupal/Core/DependencyInjection/Dumper/OptimizedPhpArrayDumper.php +++ b/core/lib/Drupal/Core/DependencyInjection/Dumper/OptimizedPhpArrayDumper.php @@ -38,6 +38,10 @@ class OptimizedPhpArrayDumper extends Dumper { /** * Whether to serialize service definitions or not. * + * Service definitions are serialized by default to avoid having to + * unserialize the whole container on loading time, which improves early + * bootstrap performance for e.g. the page cache. + * * @var bool */ protected $serialize = TRUE; diff --git a/core/lib/Drupal/Core/DependencyInjection/PhpArrayContainer.php b/core/lib/Drupal/Core/DependencyInjection/PhpArrayContainer.php index e939f4d..694098b 100644 --- a/core/lib/Drupal/Core/DependencyInjection/PhpArrayContainer.php +++ b/core/lib/Drupal/Core/DependencyInjection/PhpArrayContainer.php @@ -145,14 +145,7 @@ protected function createService($definition, $id) { $arguments = $call[1]; $arguments = $this->resolveServicesAndParameters($arguments); } - // Only use the slow call_user_func_array() when there actually are - // arguments. - if (!$arguments) { - $service->{$method}(); - } - else { - call_user_func_array(array($service, $method), $arguments); - } + call_user_func_array(array($service, $method), $arguments); } } diff --git a/core/lib/Drupal/Core/DrupalKernel.php b/core/lib/Drupal/Core/DrupalKernel.php index 4607f28..7fc8399 100644 --- a/core/lib/Drupal/Core/DrupalKernel.php +++ b/core/lib/Drupal/Core/DrupalKernel.php @@ -802,16 +802,7 @@ protected function initializeContainer() { // If the module list hasn't already been set in updateModules and we are // not forcing a rebuild, then try and load the container from the disk. if (empty($this->moduleList) && !$this->containerNeedsRebuild) { - try { - $cache = $this->bootstrapContainer->get('cache.container')->get($this->getContainerCacheKey()); - } catch (\Exception $e) { - // In the InstallerKernel the database is not available at this point. - // Not being able to load from cache is not a fatal condition, hence - // the error is ignored here. - // If the database is really not available, then it will fatal during - // service construction. - $cache = FALSE; - } + $cache = $this->bootstrapContainer->get('cache.container')->get($this->getContainerCacheKey()); if ($cache) { $container_definition = $cache->data; }