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.
Part of #2073819: [META] Remove direct calls to drupal_add_css().
Follows the same pattern that was used elsewhere, e.g. in #1969916: Remove drupal_add_js/css from seven.theme.
Comment | File | Size | Author |
---|---|---|---|
#5 | 2096591-5-theme-inc-drupal-add-css.patch | 866 bytes | mr.baileys |
#3 | 2096591-diff-1-3.txt | 1.07 KB | vijaycs85 |
#3 | 2096591-theme-css-3.patch | 908 bytes | vijaycs85 |
#1 | drupal_add_css-2096591-1.patch | 950 bytes | Wim Leers |
Comments
Comment #1
Wim LeersComment #2
andypostI think it would be good to move drupal_render() out of loop
Comment #3
vijaycs85Addressing #2
Comment #5
mr.baileysThe patch in #3 is causing a fatal error:
Tweaked the patch to avoid the error, also removed the check on empty() since drupal_render takes care of this.
Comment #6
vijaycs85Sorry for the fatal... above patch looks good to go...
Comment #7
Damien Tournoud CreditAttribution: Damien Tournoud commentedThis patch really doesn't fix *anything*. It doesn't brings us closer to removing
drupal_add_css()
, because#attach
+drupal_render()
is actually relying on the same global store for CSS information.I'm not sure why we would pursue a kick-the-can-down-the-road approach like this.
We want to remove the global store for CSS information, which means that the information needs to be stored in a data object (like a Page object) that gets passed around.
Comment #8
catch@Damien, no it's an improvement as it is, just not much of one.
drupal_render() could implement it's own internal storage, which then gets passed up properly whenever it has the opportunity to. That would help with situations like preprocess where there's nothing to #attach to, but where the theme call is actually inside a drupal_render() call that's handling #attached and caching properly. It's very much less than perfect, but at least allows that interim step to be taken.
This particular function never gets called in a place that's particularly affected by global state - it's all 'page-level' functions anyway. But we need to kill off drupal_add_css() as an API function for the places where, then circle back and look at all the direct calls to drupal_render() too. Most of the patches here have been doing #attached properly, but yes there's still plenty of places where there's nothing to #attach to and it does need sorting out.
Comment #9
Wim LeersIndeed, baby steps.
Comment #10
Damien Tournoud CreditAttribution: Damien Tournoud commentedIt's not baby step, it's kicking the can down the road. It would be more helpful to make sure that we have something to
#attach
those CSS files to in there.