Skip to content

Commit

Permalink
Fixes #2617: Perform cache rebuild during updb in same process (#2621)
Browse files Browse the repository at this point in the history
This is a backport of bc8bb69
  • Loading branch information
tstoeckler authored and weitzman committed Feb 16, 2017
1 parent 58e6678 commit 978893e
Showing 1 changed file with 20 additions and 1 deletion.
21 changes: 20 additions & 1 deletion commands/core/drupal/update.inc
Original file line number Diff line number Diff line change
Expand Up @@ -102,6 +102,25 @@ function drush_update_do_one($module, $number, $dependency_map, &$context) {
$context['message'] = 'Performing ' . $function;
}

/**
* 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 drush_update_cache_rebuild() {
drupal_flush_all_caches();
\Drupal::service('kernel')->rebuildContainer();
}

function update_main() {
// In D8, we expect to be in full bootstrap.
drush_bootstrap_to_phase(DRUSH_BOOTSTRAP_DRUPAL_FULL);
Expand Down Expand Up @@ -212,7 +231,7 @@ function drush_update_batch() {
// Apply post update hooks.
$post_updates = \Drupal::service('update.post_update_registry')->getPendingUpdateFunctions();
if ($post_updates) {
$operations[] = ['drush_drupal_cache_clear_all', []];
$operations[] = ['drush_update_cache_rebuild', []];
foreach ($post_updates as $function) {
$operations[] = ['update_invoke_post_update', [$function]];
}
Expand Down

0 comments on commit 978893e

Please sign in to comment.