Change record status: 
Project: 
Introduced in branch: 
12.1.x
Introduced in version: 
12.1.0
Description: 

The remaining functions in includes/update.inc have been deprecated and replaced with methods on the class \Drupal\Core\Update\DatabaseUpdate.

Deprecated functions

Deprecated function Method
update_already_performed($module, $number) DatabaseUpdate::alreadyPerformed($module, $number)
update_retrieve_dependencies() DatabaseUpdate::retrieveDependencies()
update_invoke_post_update($function, $context) DatabaseUpdate::invokePostUpdate($function, $context)
update_get_update_list() DatabaseUpdate::getUpdateList()
update_resolve_dependencies($starting_updates) DatabaseUpdate::resolveDependencies($starting_updates)
update_get_update_function_list($starting_updates) DatabaseUpdate::getUpdateFunctionList($starting_updates)
update_build_dependency_graph($update_functions) DatabaseUpdate::buildDependencyGraph($update_functions)
update_is_missing($module, $number, $update_functions) DatabaseUpdate::isMissing($module, $number, $update_functions)

Before/After Examples

Before

   require_once 'core/includes/update.inc';
   
   $updates = update_get_update_list(); 

After

   use \Drupal\Core\Update\DatabaseUpdate;

   $updates = \Drupal::service(DatabaseUpdate::class)->getUpdateList();

DatabaseUpdate constructor arguments added

The DatabaseUpdate::__construct method now takes the following 2 additional promoted arguments. The service is autowired so there is no need to change any code.

  • protected Drupal\Core\Update\UpdateRegistry $postUpdateRegistry
  • protected Drupal\Core\Extension\ModuleExtensionList $moduleExtensionList
Impacts: 
Module developers