Support for Drupal 7 is ending on 5 January 2025—it’s time to migrate to Drupal 10! Learn about the many benefits of Drupal 10 and find migration tools in our resource center.
Problem/Motivation
This issue is composed of two aspects:
- when processing the theme registry nested hook suggestion are not always processed in the same order;
- when nested hook suggestions are processed in the intended order (more generic suggestions first), not all preprocess functions are invoked.
Example
function mytheme_preprocess_links(&$variables) {
// ...
}
function mytheme_preprocess_links__entity(&$variables) {
// ...
}
function mytheme_preprocess_links__entity__node(&$variables) {
// ...
}
Depending on the runtime conditions when the registry is processed, theme('links__entity__node')
might end up in one of these two cases:
mytheme_preprocess_links__entity__node()
andmytheme_preprocess_links__entity()
are invoked;mytheme_preprocess_links__entity__node()
andmytheme_preprocess_links()
are invoked.
I'd expect all three preprocess functions to be invoked.
Proposed resolution
- Ensure that nested hook suggestions are always processed in a predictable order when processing the theme registry.
- Merge
(pre)process
andinclude
data so that the whole hierarchy is traversed when dealing with the most specific suggestion.
Remaining tasks
- Validate the proposed solution
- Write a patch
- Review it
User interface changes
None
API changes
This will most definitely result in a behavior change, which could be considered a BC-breaking change. OTOH the current behavior can be very tricky, as the theme may behave differently on each theme registry rebuild.
Data model changes
None
Release notes snippet
TBD
Comment | File | Size | Author |
---|---|---|---|
#2 | bootstrap-3048606-2.patch | 926 bytes | plach |
Comments
Comment #2
plachThis implements only part 1 of the proposed solution.
Comment #3
plachComment #4
markhalliwell