Skip to content

Commit

Permalink
Fixes drush-ops#2671: Perform cache rebuild during updb in same proce…
Browse files Browse the repository at this point in the history
  • Loading branch information
tstoeckler authored and mikeker committed Aug 4, 2017
1 parent 0b74bc0 commit 901b8d1
Showing 1 changed file with 20 additions and 1 deletion.
21 changes: 20 additions & 1 deletion lib/Drush/Commands/core/UpdateDBCommands.php
Expand Up @@ -286,7 +286,7 @@ function updateBatch($options) {
// Apply post update hooks.
$post_updates = \Drupal::service('update.post_update_registry')->getPendingUpdateFunctions();
if ($post_updates) {
$operations[] = ['drush_drupal_cache_clear_all', []];
$operations[] = [[$this, 'cacheRebuild'], []];
foreach ($post_updates as $function) {
$operations[] = ['update_invoke_post_update', [$function]];
}
Expand Down Expand Up @@ -346,6 +346,25 @@ function getUpdateList() {
return $return;
}

/**
* Clears caches and rebuilds the container.
*
* This is called in between regular updates and post updates. Do not use
* drush_drupal_cache_clear_all() as the cache clearing and container rebuild
* must happen in the same process that the updates are run in.
*
* Drupal core's update.php uses drupal_flush_all_caches() directly without
* explicitly rebuilding the container as the container is rebuilt on the next
* HTTP request of the batch.
*
* @see drush_drupal_cache_clear_all()
* @see \Drupal\system\Controller\DbUpdateController::triggerBatch()
*/
function cacheRebuild() {
drupal_flush_all_caches();
\Drupal::service('kernel')->rebuildContainer();
}

/**
* Process and display any returned update output.
*
Expand Down

0 comments on commit 901b8d1

Please sign in to comment.