Details
-
Type: Bug
-
Status: Done/Fixed
-
Priority: Minor
-
Resolution: Fixed/Completed
-
Affects Version/s: 4.3.0
-
Fix Version/s: 4.3.2
-
Component/s: None
-
Labels:None
Description
CRM_Utils_Hook_Drupal::invoke() calls CRM_Utils_Hook::requireCiviModules() to add extensions to the list of Drupal modules. requireCiviModules() operates by appending extensions to the end of $moduleList.
Drupal uses a primitive but effective way to enforce a module-by-module hook invocation order by assigning each module a weight. Those modules that need to run "later" typically assign themselves a high weight so that other hook implementations run first. The civicrm module itself uses a weight of 100, a respectably high number. This means that if I need my module's hooks to run after civicrm's I need only give it a weight > 100.
By appending extensions to the end of the Drupal module list, requireCiviModules() is essentially assigning extensions a weight of infinity. This means that there is no way for another module to make sure its hooks run after any hooks implemented by extensions. For example, it is not possible to override the access arguments of the cividiscount extension menu items by implementing hook_civicrm_xmlMenu() because cividiscount's implementation of hook_civicrm_xmlMenu() that creates the menu items doesn't get invoked until after all standard Drupal modules have had their hooks run.
I propose requireCiviModules() insert extensions into the module list immediately after the 'civicrm' entry, thereby assigning them the same weight as civicrm itself.
I have a patch which I will try to get into a PR.