Loading core/includes/common.inc +4 −2 Changes for core/includes/common.inc: 4 added lines, 2 removed lines. Original line number Diff line number Diff line Loading @@ -1295,8 +1295,10 @@ function drupal_flush_all_caches() { // Reset all static caches. drupal_static_reset(); // Wipe the PHP Storage caches. PhpStorageFactory::get('service_container')->deleteAll(); // Invalidate the container. \Drupal::service('kernel')->invalidateContainer(); // Wipe the Twig PHP Storage cache. PhpStorageFactory::get('twig')->deleteAll(); // Rebuild module and theme data. Loading core/includes/utility.inc +6 −2 Changes for core/includes/utility.inc: 6 added lines, 2 removed lines. Original line number Diff line number Diff line Loading @@ -29,13 +29,17 @@ function drupal_rebuild(ClassLoader $class_loader, Request $request) { restore_error_handler(); restore_exception_handler(); // Force kernel to rebuild container. PhpStorageFactory::get('service_container')->deleteAll(); // Force kernel to rebuild php cache. PhpStorageFactory::get('twig')->deleteAll(); // Bootstrap up to where caches exist and clear them. $kernel = new DrupalKernel('prod', $class_loader); $kernel->setSitePath(DrupalKernel::findSitePath($request)); // Invalidate the container. $kernel->invalidateContainer(); // Prepare a NULL request. $kernel->prepareLegacyRequest($request); foreach (Cache::getBins() as $bin) { Loading core/lib/Drupal/Core/DrupalKernel.php +40 −12 Changes for core/lib/Drupal/Core/DrupalKernel.php: 40 added lines, 12 removed lines. Original line number Diff line number Diff line Loading @@ -126,6 +126,13 @@ class DrupalKernel implements DrupalKernelInterface, TerminableInterface { */ protected $allowDumping; /** * Whether the container needs to be rebuilt the next time it is initialized. * * @var bool */ protected $containerNeedsRebuild = FALSE; /** * Whether the container needs to be dumped once booting is complete. * Loading Loading @@ -695,11 +702,13 @@ public function updateModules(array $module_list, array $module_filenames = arra } // If we haven't yet booted, we don't need to do anything: the new module // list will take effect when boot() is called. If we have already booted, // then rebuild the container in order to refresh the serviceProvider list // and container. // list will take effect when boot() is called. However we set a // flag that the container needs a rebuild, so that a potentially cached // container is not used. If we have already booted, then rebuild the // container in order to refresh the serviceProvider list and container. $this->containerNeedsRebuild = TRUE; if ($this->booted) { $this->initializeContainer(TRUE); $this->initializeContainer(); } } Loading Loading @@ -738,11 +747,9 @@ protected function getKernelParameters() { /** * Initializes the service container. * * @param bool $rebuild * Force a container rebuild. * @return \Symfony\Component\DependencyInjection\ContainerInterface */ protected function initializeContainer($rebuild = FALSE) { protected function initializeContainer() { $this->containerNeedsDumping = FALSE; $session_started = FALSE; if (isset($this->container)) { Loading @@ -764,7 +771,7 @@ protected function initializeContainer($rebuild = FALSE) { // 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) && !$rebuild) { if (empty($this->moduleList) && !$this->containerNeedsRebuild) { $fully_qualified_class_name = '\\' . $this->getClassNamespace() . '\\' . $this->getClassName(); // First, try to load from storage. Loading @@ -781,6 +788,9 @@ protected function initializeContainer($rebuild = FALSE) { $container = $this->compileContainer(); } // The container was rebuilt successfully. $this->containerNeedsRebuild = FALSE; $this->attachSynthetic($container); $this->container = $container; Loading Loading @@ -998,15 +1008,33 @@ protected function persistServices(ContainerInterface $container, array $persist } /** * Force a container rebuild. * * @return \Symfony\Component\DependencyInjection\ContainerInterface * {@inheritdoc} */ public function rebuildContainer() { // Empty module properties and for them to be reloaded from scratch. $this->moduleList = NULL; $this->moduleData = array(); return $this->initializeContainer(TRUE); $this->containerNeedsRebuild = TRUE; return $this->initializeContainer(); } /** * {@inheritdoc} */ public function invalidateContainer() { // An invalidated container needs a rebuild. $this->containerNeedsRebuild = TRUE; // If we have not yet booted, settings or bootstrap services might not yet // be available. In that case the container will not be loaded from cache // due to the above setting when the Kernel is booted. if (!$this->booted) { return; } // Also wipe the PHP Storage caches, so that the container is rebuilt // for the next request. $this->storage()->deleteAll(); } /** Loading core/lib/Drupal/Core/DrupalKernelInterface.php +12 −0 Changes for core/lib/Drupal/Core/DrupalKernelInterface.php: 12 added lines, 0 removed lines. Original line number Diff line number Diff line Loading @@ -96,6 +96,18 @@ public function getAppRoot(); */ public function updateModules(array $module_list, array $module_filenames = array()); /** * Force a container rebuild. * * @return \Symfony\Component\DependencyInjection\ContainerInterface */ public function rebuildContainer(); /** * Invalidate the service container for the next request. */ public function invalidateContainer(); /** * Prepare the kernel for handling a request without handling the request. * Loading core/lib/Drupal/Core/Installer/InstallerKernel.php +4 −6 Changes for core/lib/Drupal/Core/Installer/InstallerKernel.php: 4 added lines, 6 removed lines. Original line number Diff line number Diff line Loading @@ -16,13 +16,11 @@ class InstallerKernel extends DrupalKernel { /** * {@inheritdoc} * * @param bool $rebuild * Force a container rebuild. Unlike the parent method, this defaults to * TRUE. */ protected function initializeContainer($rebuild = TRUE) { $container = parent::initializeContainer($rebuild); protected function initializeContainer() { // Always force a container rebuild. $this->containerNeedsRebuild = TRUE; $container = parent::initializeContainer(); return $container; } Loading Loading
core/includes/common.inc +4 −2 Changes for core/includes/common.inc: 4 added lines, 2 removed lines. Original line number Diff line number Diff line Loading @@ -1295,8 +1295,10 @@ function drupal_flush_all_caches() { // Reset all static caches. drupal_static_reset(); // Wipe the PHP Storage caches. PhpStorageFactory::get('service_container')->deleteAll(); // Invalidate the container. \Drupal::service('kernel')->invalidateContainer(); // Wipe the Twig PHP Storage cache. PhpStorageFactory::get('twig')->deleteAll(); // Rebuild module and theme data. Loading
core/includes/utility.inc +6 −2 Changes for core/includes/utility.inc: 6 added lines, 2 removed lines. Original line number Diff line number Diff line Loading @@ -29,13 +29,17 @@ function drupal_rebuild(ClassLoader $class_loader, Request $request) { restore_error_handler(); restore_exception_handler(); // Force kernel to rebuild container. PhpStorageFactory::get('service_container')->deleteAll(); // Force kernel to rebuild php cache. PhpStorageFactory::get('twig')->deleteAll(); // Bootstrap up to where caches exist and clear them. $kernel = new DrupalKernel('prod', $class_loader); $kernel->setSitePath(DrupalKernel::findSitePath($request)); // Invalidate the container. $kernel->invalidateContainer(); // Prepare a NULL request. $kernel->prepareLegacyRequest($request); foreach (Cache::getBins() as $bin) { Loading
core/lib/Drupal/Core/DrupalKernel.php +40 −12 Changes for core/lib/Drupal/Core/DrupalKernel.php: 40 added lines, 12 removed lines. Original line number Diff line number Diff line Loading @@ -126,6 +126,13 @@ class DrupalKernel implements DrupalKernelInterface, TerminableInterface { */ protected $allowDumping; /** * Whether the container needs to be rebuilt the next time it is initialized. * * @var bool */ protected $containerNeedsRebuild = FALSE; /** * Whether the container needs to be dumped once booting is complete. * Loading Loading @@ -695,11 +702,13 @@ public function updateModules(array $module_list, array $module_filenames = arra } // If we haven't yet booted, we don't need to do anything: the new module // list will take effect when boot() is called. If we have already booted, // then rebuild the container in order to refresh the serviceProvider list // and container. // list will take effect when boot() is called. However we set a // flag that the container needs a rebuild, so that a potentially cached // container is not used. If we have already booted, then rebuild the // container in order to refresh the serviceProvider list and container. $this->containerNeedsRebuild = TRUE; if ($this->booted) { $this->initializeContainer(TRUE); $this->initializeContainer(); } } Loading Loading @@ -738,11 +747,9 @@ protected function getKernelParameters() { /** * Initializes the service container. * * @param bool $rebuild * Force a container rebuild. * @return \Symfony\Component\DependencyInjection\ContainerInterface */ protected function initializeContainer($rebuild = FALSE) { protected function initializeContainer() { $this->containerNeedsDumping = FALSE; $session_started = FALSE; if (isset($this->container)) { Loading @@ -764,7 +771,7 @@ protected function initializeContainer($rebuild = FALSE) { // 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) && !$rebuild) { if (empty($this->moduleList) && !$this->containerNeedsRebuild) { $fully_qualified_class_name = '\\' . $this->getClassNamespace() . '\\' . $this->getClassName(); // First, try to load from storage. Loading @@ -781,6 +788,9 @@ protected function initializeContainer($rebuild = FALSE) { $container = $this->compileContainer(); } // The container was rebuilt successfully. $this->containerNeedsRebuild = FALSE; $this->attachSynthetic($container); $this->container = $container; Loading Loading @@ -998,15 +1008,33 @@ protected function persistServices(ContainerInterface $container, array $persist } /** * Force a container rebuild. * * @return \Symfony\Component\DependencyInjection\ContainerInterface * {@inheritdoc} */ public function rebuildContainer() { // Empty module properties and for them to be reloaded from scratch. $this->moduleList = NULL; $this->moduleData = array(); return $this->initializeContainer(TRUE); $this->containerNeedsRebuild = TRUE; return $this->initializeContainer(); } /** * {@inheritdoc} */ public function invalidateContainer() { // An invalidated container needs a rebuild. $this->containerNeedsRebuild = TRUE; // If we have not yet booted, settings or bootstrap services might not yet // be available. In that case the container will not be loaded from cache // due to the above setting when the Kernel is booted. if (!$this->booted) { return; } // Also wipe the PHP Storage caches, so that the container is rebuilt // for the next request. $this->storage()->deleteAll(); } /** Loading
core/lib/Drupal/Core/DrupalKernelInterface.php +12 −0 Changes for core/lib/Drupal/Core/DrupalKernelInterface.php: 12 added lines, 0 removed lines. Original line number Diff line number Diff line Loading @@ -96,6 +96,18 @@ public function getAppRoot(); */ public function updateModules(array $module_list, array $module_filenames = array()); /** * Force a container rebuild. * * @return \Symfony\Component\DependencyInjection\ContainerInterface */ public function rebuildContainer(); /** * Invalidate the service container for the next request. */ public function invalidateContainer(); /** * Prepare the kernel for handling a request without handling the request. * Loading
core/lib/Drupal/Core/Installer/InstallerKernel.php +4 −6 Changes for core/lib/Drupal/Core/Installer/InstallerKernel.php: 4 added lines, 6 removed lines. Original line number Diff line number Diff line Loading @@ -16,13 +16,11 @@ class InstallerKernel extends DrupalKernel { /** * {@inheritdoc} * * @param bool $rebuild * Force a container rebuild. Unlike the parent method, this defaults to * TRUE. */ protected function initializeContainer($rebuild = TRUE) { $container = parent::initializeContainer($rebuild); protected function initializeContainer() { // Always force a container rebuild. $this->containerNeedsRebuild = TRUE; $container = parent::initializeContainer(); return $container; } Loading