Drupal7 update hook dependencies


You sometimes find that update hooks run in an unwanted order that affects their behaviour or creates errors and makes your site crash. You can override this and specify the order that you want with the following hook in your .install file.

 function new_module_update_dependencies() {
  // Run new_module update after old_module update.
  $dependencies['new_module'][7001] = array(
    'old_module' => 7000,
  );
 
  return $dependencies;
 }

Drupal Update Hook Dependencies


Sometimes, when developing an update hook, you might want it to run after or before a different module’s update hook. this is the way to do it:

Place the following code into your module’s mymodule.install file.

Where 7001 and 7140 are the hook update number.

/**
 * Implementation of hook_update_dependencies().
*/
function mymodule_update_dependencies() {
  // Make sure that mymodule runs after other_module
  $dependencies['mymodule'][7001] = 
 'other_module' => 7140,
);
  return $dependencies;
}