Problem/Motivation
Drupal stores compiler-generated hook metadata in the hook_data key-value collection:
- hook_list
- packed_order_operations
- theme_hook_list
- preprocess_for_suggestions
The three consumers own overlapping loading and caching logic:
- ModuleHandler loads and caches hook_list plus packed_order_operations.
- ThemeManager loads and caches theme_hook_list.
- Registry separately reads theme_hook_list and preprocess_for_suggestions directly from key-value storage.
On a cold cache, both Registry and ThemeManager independently load theme_hook_list.
Steps to reproduce
Proposed resolution
Introduce a HookData service that owns the compiler-generated hook_data reads and the bootstrap cache entries.
Use two logical cache groups:
1. Module hook data: hook_list and packed_order_operations
2. Theme hook data: theme_hook_list and preprocess_for_suggestions.
ModuleHandler, ThemeManager, and Registry would use this shared service. The service keeps request-local copies, reads from cache.bootstrap first, and falls back to the key-value collection on a cache miss.
This should remove two database queries from the cold cache performance tests.
Remaining tasks
User interface changes
Introduced terminology
API changes
Data model changes
Release notes snippet
| Comment | File | Size | Author |
|---|
Issue fork drupal-3618707
Show commands
Start within a Git clone of the project using the version control instructions.
Or, if you do not have SSH keys set up on git.drupalcode.org:
Comments
Comment #4
longwaveComment #5
nicxvan commentedWe might also be able to better handle race conditions is we move to a container cache key for the hook data.
Comment #6
nicxvan commentedClosing duplicate: #3560635: Theme hook list key/value lookup runs twice on cold caches
Comment #7
needs-review-queue-bot commentedThe Needs Review Queue Bot tested this issue. It no longer applies to Drupal core. Therefore, this issue status is now "Needs work".
This does not mean that the patch necessarily needs to be re-rolled or the MR rebased. Read the Issue Summary, the issue tags and the latest discussion here to determine what needs to be done.
Consult the Drupal Contributor Guide to find step-by-step guides for working with issues.
Comment #8
longwaveComment #9
nicxvan commentedWe need to regenerate the performance tests, this looks great.
We probably need a CR too since we're breaking BC on these classes again.
Comment #10
longwaveComment #11
nicxvan commentedAdded the CR!
Needs a reroll and review of the change record though.
Comment #12
longwaveI added a BC layer and pointed to the CR, but I think the CR needs a bit more detail about what to do if you were overriding the services before - contrib does extend some of these, such as Bootstrap reusing Registry.
Comment #13
nicxvan commentedLooks great now!
I updated the CR to mention the new constructor changes, @longwave approved in slack: https://drupal.slack.com/archives/C079NQPQUEN/p1791809011440739
I reviewed everything again and we tidied up the tests a bit.