function hook_update_dependencies

Same name in other branches
  1. 9 core/lib/Drupal/Core/Extension/module.api.php \hook_update_dependencies()
  2. 8.9.x core/lib/Drupal/Core/Extension/module.api.php \hook_update_dependencies()
  3. 10 core/lib/Drupal/Core/Extension/module.api.php \hook_update_dependencies()
  4. 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

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

update_resolve_dependencies()

hook_update_N()

Related topics

13 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.

block_update_dependencies in modules/block/block.install
Implements hook_update_dependencies().
comment_update_dependencies in modules/comment/comment.install
Implements hook_update_dependencies().
contact_update_dependencies in modules/contact/contact.install
Implements hook_update_dependencies().
filter_update_dependencies in modules/filter/filter.install
Implements hook_update_dependencies().
forum_update_dependencies in modules/forum/forum.install
Implements hook_update_dependencies().

... See full list

File

modules/system/system.api.php, line 3571

Code

function hook_update_dependencies() {
    // Indicate that the mymodule_update_7000() function provided by this module
    // must run after the another_module_update_7002() function provided by the
    // 'another_module' module.
    $dependencies['mymodule'][7000] = array(
        'another_module' => 7002,
    );
    // Indicate that the mymodule_update_7001() function provided by this module
    // must run before the yet_another_module_update_7004() 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'][7004] = array(
        'mymodule' => 7001,
    );
    return $dependencies;
}

Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.