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

ModuleHandler skips all hook implementations when invoked before the module files have been loaded

$
0
0

Problem/Motivation

Under certain circumstances the module files are not yet loaded.

This happens for example when invoking a hook inside the constructor of a http_middleware service; theses services are constructed very early as a dependency of http_kernel service.

A more concrete example is a middleware service using the entity_type.manager. Most of the times the entity type information is retrieved from cache (stored in the discovery cache bin). When this cache however is missing, hooks like hook_entity_type_build() and hook_entity_type_alter() need to be invoked at this early stage. The modules files however haven't been loaded yet, making ModuleHanlder::verifyImplementations() skip all the hook implementations (silently!). The entity definition cache is then incomplete resulting in various hard to debug (next to impossible) exceptions like #3031598: The "paragraph" entity type did not specify a translation handler. .

Steps to reproduce

TODO

Proposed resolution

If a hook is invoked before the modules being loaded, load all modules.

Remaining tasks

Update issue summary
Address #12 and #17


Viewing all articles
Browse latest Browse all 299191

Latest Images

Trending Articles



Latest Images

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