Quantcast
Channel: Issues for Drupal core
Viewing all articles
Browse latest Browse all 302528

Don't do a registry_update() before installing a module

$
0
0

It is expected that module hook_update_N() implementations should not use the module's own APIs, but that is not for the module's hook_schema(), hook_install() or hook_enable() implementations.

Drupal 7's module_enable()'s workflow is roughly as follows:

  1. Load mymodule.module file.
  2. Load mymodule.install file.
  3. Update the {system} table to mark the module as being enabled.
  4. Reset the cached list of system files.
  5. Clear the cached list of module files.
  6. Clear the cached list of hook implementations.
  7. Reload the system registry to include all files identified in the previous steps.
  8. Clear the cached schema.
  9. Clear the entity info cache.
  10. Install the new module's schema.
  11. Update the module's schema_revision value to the numerically highest hook_update_N() implementation.
  12. Run the module's hook_install() implementation, if present.
  13. Run the module's hook_enable() implementation, if present.

It's worth noting that step 7 causes any implementations of hook_registry_files_alter() to execute, which can lead to unexpected problems, like Media module not installing or the same with Styles module.

What I would recommend is changing the installation process to not load the module file, rely on the hook_install() to instead deal with any custom logic on its own and only run registry_update() after the module has been properly installed.


Viewing all articles
Browse latest Browse all 302528

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>