Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Run theme post updates when supported by core #5120

Merged
merged 3 commits into from Apr 13, 2022
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
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