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.
This is a meta issue to track proposed changes to template_preprocess().
Main motivations:
- Some of what template_preprocess() does no longer makes sense now that we are converting theme_*() functions to templates - #1938430: Don't add a default theme hook class in template_preprocess()
- Performance should be much improved.
Issues:
#1938430: Don't add a default theme hook class in template_preprocess()
#1982024: Lazy-load Attribute objects later in the rendering process only if needed
#1982020: Add static caching to drupal_html_class()
#2340341: Move template_preprocess, _template_preprocess_default_variables into services
Comments
Comment #0.0
star-szrAdd more issues
Comment #0.1
star-szrUpdated issue summary.
Comment #1
c4rl CreditAttribution: c4rl commentedPer #1938430-18: Don't add a default theme hook class in template_preprocess(), my original intention of that issue was to remove template_preprocess() entirely, and I would still like that to happen.
Frankly, I think #1982024: Lazy-load Attribute objects later in the rendering process only if needed perpetuates an anti-pattern. What do we gain by assuming every template contains `attributes,` `title_attributes,` and `content_attributes` whilst any other presence of another Attribute object in a template would require invocation anyway via `new Attribute` in a subsequent preprocessor?
Really, I'm curious of what would be wrong with invoking `new Attribute` on a case-by-case basis. I think assuming that every templates wants these goes some of the Principles we established at BADCamp 2012.
Comment #1.0
c4rl CreditAttribution: c4rl commentedUpdated issue summary.
Comment #2
joelpittetI agree with @c4rl in #1 entirely. Though undoing that "anti-pattern" is harder than it sounds due to the prevalence of
NestedArray::mergeDeepArray
. I got half way there with this issue #2108771: Remove special cased title_attributes and content_attributes for Attribute creation.And regarding removing template_preprocess(). It will need to be done delicately so we don't break things but that would be a nice thing to do as well:)
Comment #3
jiv_e CreditAttribution: jiv_e as a volunteer commentedComment #4
jiv_e CreditAttribution: jiv_e as a volunteer commentedComment #5
joelpittetLikely 9.x
Comment #6
catch#2340341: Move template_preprocess, _template_preprocess_default_variables into services is the only remaining issue from the summary, and is in progress against 8.3.x, so closing this.