Using entity_get_info in a hook_hook_info results in an incomplete module_implements cache.

Created on 24 January 2012, almost 13 years ago
Updated 13 May 2023, over 1 year ago

If a hook_info hook uses entity_get_info() this will result in an incomplete module_implements() cache:

  1. _drupal_bootstrap_full() calls file_get_stream_wrappers()
  2. file_get_stream_wrappers() calls module_invoke_all()
  3. module_invoke_all() calls module_implements()
  4. module_implements() calls module_hook_info()
  5. module_hook_info() initializes a static $hook_info array and runs any X_hook_info() it can find
  6. some module's X_hook_info() uses entity_get_info()
  7. entity_get_info() calls module_invoke_all()
  8. module_invoke_all() calls module_implements()
  9. module_implements() (which caches its result) calls module_hook_info()
  10. module_hook_info() returns the empty static array because it was initialized
  11. module_implements() keeps a bad implementations cache

All of this can result in weird behavior. I found that after an apachesolr module update (which now uses entity_get_info in its hook_info) that my field labels all got the same translation as the first field in the form. This was caused by i18n not being able to find submodules which implement i18n_object_info hooks.

These issues are related:

http://drupal.org/node/968264
http://drupal.org/node/1410256

I think we simply can't allow any hook_hook_info() to use entity_get_info() or any other function which leads up to module_hook_info()?

🐛 Bug report
Status

Needs review

Version

7.0 ⚰️

Component
Base 

Last updated about 11 hours ago

Created by

🇧🇪Belgium joericapens

Live updates comments and jobs are added and updated live.
Sign in to follow issues

Comments & Activities

Not all content is available!

It's likely this issue predates Contrib.social: some issue and comment data are missing.

Production build 0.71.5 2024