drupal_check_module() invokes hook_requirements on a specific module, to determine whether it can be safely enabled.
drupal_check_module() is called from
- ModulesListForm::buildModuleList (Drupal 8)
- drush_pm_enable_validate() (drush)
- system_modules_submit() (Drupal 7)
- features_form_validate() (Features in Drupal 7 contrib)
Scenario (Drupal 7):
- views_content_ds depends on xautoload.
- Let's assume both of these modules implement hook_requirements().
- Both modules are disabled.
- I run drush en views_content_ds, which would trigger enabling of both modules.
Observed result:
- views_content_ds_requirements() runs before xautoload_requirements().
This is unfortunate, because I would like to do some feature detection in views_content_ds, which only works if xautoload has a chance to run its own hook_requirements() beforehand.
Proposed solution:
- run drupal_check_module() checks in an order that respects module dependencies.
- factor this order management out of form submit handlers, into a separate, reusable function or class.
(The scenario I describe may be very specific, but I think it would still be generally useful)
Comments