File tree Expand file tree Collapse file tree 1 file changed +20
-1
lines changed Expand file tree Collapse file tree 1 file changed +20
-1
lines changed Original file line number Diff line number Diff line change @@ -286,7 +286,7 @@ function updateBatch($options) {
286286 // Apply post update hooks.
287287 $ post_updates = \Drupal::service ('update.post_update_registry ' )->getPendingUpdateFunctions ();
288288 if ($ post_updates ) {
289- $ operations [] = [' drush_drupal_cache_clear_all ' , []];
289+ $ operations [] = [[ $ this , ' cacheRebuild ' ] , []];
290290 foreach ($ post_updates as $ function ) {
291291 $ operations [] = ['update_invoke_post_update ' , [$ function ]];
292292 }
@@ -346,6 +346,25 @@ function getUpdateList() {
346346 return $ return ;
347347 }
348348
349+ /**
350+ * Clears caches and rebuilds the container.
351+ *
352+ * This is called in between regular updates and post updates. Do not use
353+ * drush_drupal_cache_clear_all() as the cache clearing and container rebuild
354+ * must happen in the same process that the updates are run in.
355+ *
356+ * Drupal core's update.php uses drupal_flush_all_caches() directly without
357+ * explicitly rebuilding the container as the container is rebuilt on the next
358+ * HTTP request of the batch.
359+ *
360+ * @see drush_drupal_cache_clear_all()
361+ * @see \Drupal\system\Controller\DbUpdateController::triggerBatch()
362+ */
363+ function cacheRebuild () {
364+ drupal_flush_all_caches ();
365+ \Drupal::service ('kernel ' )->rebuildContainer ();
366+ }
367+
349368 /**
350369 * Process and display any returned update output.
351370 *
You can’t perform that action at this time.
0 commit comments