diff --git a/core/modules/system/src/Controller/DbUpdateController.php b/core/modules/system/src/Controller/DbUpdateController.php index fdedcc6..db0a6e4 100644 --- a/core/modules/system/src/Controller/DbUpdateController.php +++ b/core/modules/system/src/Controller/DbUpdateController.php @@ -4,6 +4,7 @@ use Drupal\Core\Cache\CacheBackendInterface; use Drupal\Core\Controller\ControllerBase; +use Drupal\Core\DrupalKernelInterface; use Drupal\Core\Extension\ModuleHandlerInterface; use Drupal\Core\KeyValueStore\KeyValueExpirableFactoryInterface; use Drupal\Core\Render\BareHtmlPageRendererInterface; @@ -611,7 +612,7 @@ protected function triggerBatch(Request $request) { if ($post_updates) { // Now we rebuild all caches and after that execute the hook_post_update() // functions. - $operations[] = ['drupal_flush_all_caches', []]; + $operations[] = [[static::class, 'cacheRebuild'], []]; foreach ($post_updates as $function) { $operations[] = ['update_invoke_post_update', [$function]]; } @@ -631,6 +632,23 @@ protected function triggerBatch(Request $request) { } /** + * Clears caches and rebuilds the container. + * + * This is called in between regular updates and post updates. + * + * drupal_flush_all_caches() will invalidate the container without rebuilding + * it, which is not necessary as the container is rebuilt on the next HTTP + * request of the batch, but in order to be clear what happens and what + * should happen before executing the post updates we explicitly rebuild the + * container, which should be done as well if the updates are executed + * through e.g. drush. + */ + public static function cacheRebuild() { + drupal_flush_all_caches(); + \Drupal::service('kernel')->rebuildContainer(); + } + + /** * Finishes the update process and stores the results for eventual display. * * After the updates run, all caches are flushed. The update results are