Let's say that there is a contributed module installed in Drupal 7. It alters a SQL statement from the core. Now I have a custom module of my own which alters the same SQL statement in a different way. Now, depending on the alteration, I could have different SQL strings depending on which module hook applies before the other. For example, the first hook deletes a table "field" and the other adds the same table "field". If the first hooks executes earlier, the final SQL has the field added. If it is now the second hook which executes earlier, the extra field is added and later removed, so the SQL is completely different. How can I now the priority, any other conflicting issues and is there a way to override this apparent difficulty?


1 Answer 1


The system table has a 'weight' field. The hooks are executed in that order.

You can change during install with this code:

function your_module_name_install() {
    ->fields(array('weight' => your_preferred_weight))
    ->condition('name', '[your_module_name]', '=')

Source: https://www.drupal.org/node/110238

Not the answer you're looking for? Browse other questions tagged or ask your own question.