Skip to content

Commit

Permalink
Run theme post updates when supported by core (#5120)
Browse files Browse the repository at this point in the history
  • Loading branch information
alexpott committed Apr 13, 2022
1 parent cd91051 commit 0a807a8
Showing 1 changed file with 14 additions and 7 deletions.
21 changes: 14 additions & 7 deletions src/Commands/core/UpdateDBCommands.php
Expand Up @@ -265,11 +265,18 @@ public static function updateDoOnePostUpdate(string $function, DrushBatchContext
return;
}

list($module, $name) = explode('_post_update_', $function, 2);
$filename = $module . '.post_update';
\Drupal::moduleHandler()->loadInclude($module, 'php', $filename);
list($extension, $name) = explode('_post_update_', $function, 2);
$update_registry = \Drupal::service('update.post_update_registry');
// https://www.drupal.org/project/drupal/issues/3259188 Support theme's
// having post update functions when it is supported in Drupal core.
if (method_exists($update_registry, 'getUpdateFunctions')) {
\Drupal::service('update.post_update_registry')->getUpdateFunctions($extension);
} else {
\Drupal::service('update.post_update_registry')->getModuleUpdateFunctions($extension);
}

if (function_exists($function)) {
if (empty($context['results'][$module][$name]['type'])) {
if (empty($context['results'][$extension][$name]['type'])) {
Drush::logger()->notice("Update started: $function");
}
try {
Expand Down Expand Up @@ -306,10 +313,10 @@ public static function updateDoOnePostUpdate(string $function, DrushBatchContext
$context['finished'] = $context['sandbox']['#finished'];
unset($context['sandbox']['#finished']);
}
if (!isset($context['results'][$module][$name])) {
$context['results'][$module][$name] = [];
if (!isset($context['results'][$extension][$name])) {
$context['results'][$extension][$name] = [];
}
$context['results'][$module][$name] = array_merge($context['results'][$module][$name], $ret);
$context['results'][$extension][$name] = array_merge($context['results'][$extension][$name], $ret);

// Log the message that was returned.
if (!empty($ret['results']['query'])) {
Expand Down

0 comments on commit 0a807a8

Please sign in to comment.