Change record status: 
Project: 
Introduced in branch: 
11.5.x
Introduced in version: 
11.5.0
Description: 

\Drupal\Core\Update\DatabaseUpdate::getPendingUpdates() is a new method. It returns all pending hook_update_N() implementations and post-update functions, grouped by extension. Each update reports if it can run and which dependencies are missing.

$pending = \Drupal::service(\Drupal\Core\Update\DatabaseUpdate::class)->getPendingUpdates();
foreach ($pending as $extension => $info) {
  // $info['type'] is 'module' or 'theme'.
  // $info['warning'] is NULL, or the reason no hook_update_N() can run.
  foreach ($info['updates'] as $update) {
    // Keys: type ('update' or 'post_update'), name, function, description,
    // allowed, missing_dependencies.
  }
}

Code that combined update_get_update_list(), update_resolve_dependencies() and UpdateRegistry::getPendingUpdateInformation() can call this method.

DatabaseUpdate::__construct() has a new $postUpdateRegistry argument.

Generated with the help of an LLM.

Impacts: 
Module developers