function hook_update_dependencies
Same name in other branches
- 7.x modules/system/system.api.php \hook_update_dependencies()
- 8.9.x core/lib/Drupal/Core/Extension/module.api.php \hook_update_dependencies()
- 10 core/lib/Drupal/Core/Extension/module.api.php \hook_update_dependencies()
- 11.x core/lib/Drupal/Core/Extension/module.api.php \hook_update_dependencies()
Return an array of information about module update dependencies.
This can be used to indicate update functions from other modules that your module's update functions depend on, or vice versa. It is used by the update system to determine the appropriate order in which updates should be run, as well as to search for missing dependencies.
Implementations of this hook should be placed in a mymodule.install file in the same directory as mymodule.module.
Return value
array A multidimensional array containing information about the module update dependencies. The first two levels of keys represent the module and update number (respectively) for which information is being returned, and the value is an array of information about that update's dependencies. Within this array, each key represents a module, and each value represents the number of an update function within that module. In the event that your update function depends on more than one update from a particular module, you should always list the highest numbered one here (since updates within a given module always run in numerical order).
See also
Related topics
3 functions implement hook_update_dependencies()
Note: this list is generated by pattern matching, so it may include some functions that are not actually implementations of this hook.
- update_test_1_update_dependencies in core/
modules/ system/ tests/ modules/ update_test_1/ update_test_1.install - Implements hook_update_dependencies().
- update_test_2_update_dependencies in core/
modules/ system/ tests/ modules/ update_test_2/ update_test_2.install - Implements hook_update_dependencies().
- update_test_3_update_dependencies in core/
modules/ system/ tests/ modules/ update_test_3/ update_test_3.install - Implements hook_update_dependencies().
File
-
core/
lib/ Drupal/ Core/ Extension/ module.api.php, line 852
Code
function hook_update_dependencies() {
// Indicate that the mymodule_update_8001() function provided by this module
// must run after the another_module_update_8003() function provided by the
// 'another_module' module.
$dependencies['mymodule'][8001] = [
'another_module' => 8003,
];
// Indicate that the mymodule_update_8002() function provided by this module
// must run before the yet_another_module_update_8005() function provided by
// the 'yet_another_module' module. (Note that declaring dependencies in this
// direction should be done only in rare situations, since it can lead to the
// following problem: If a site has already run the yet_another_module
// module's database updates before it updates its codebase to pick up the
// newest mymodule code, then the dependency declared here will be ignored.)
$dependencies['yet_another_module'][8005] = [
'mymodule' => 8002,
];
return $dependencies;
}
Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.