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.
https://api.drupal.org/api/drupal/core%21includes%21common.inc/function/...
This can be replaced with #attached['drupal_add_html_head_link']
Would be good to use a different string, but using #attached is higher priority than finding a new string identifier I think.
Comment | File | Size | Author |
---|---|---|---|
#13 | drupal_add_html_head_link-2115061-13.patch | 6.14 KB | JeroenT |
Comments
Comment #1
JeroenTReplaced drupal_add_html_head_link with #attached.
Patch attached.
Comment #2
BerdirPatch is empty.
Comment #3
JeroenTI'm sorry. This is the right one.
Comment #5
JeroenTGuess who's back with a brand new patch!
Comment #6
tim.plunkettMissing trailing comma
Here and throughout, these could be condensed onto one line and the innards could be outdented
This is indented incorrectly.
Comment #7
JeroenTComment #8
JeroenTMade some coding standards changes as suggested by tim.plunkett.
Comment #9
JeroenTMarking as needs review.
Comment #10
tim.plunkettThat's not exactly what I had in mind for indentation.
Also are we 100% sure we need each of those drupal_render calls? It seems like some of them are in the context of a render array already. And there are more than one drupal_render call in the same function...
Comment #11
JeroenTI deleted some of the unnecessary drupal_render calls.
I think we can also remove this drupal_render in /core/includes/common.inc by replacing the theme function with a renderable array.
In /core/includes/theme.inc there is already a drupal_render call to add the default_css files, Maybe we can use this one also to add the html_link_head?
Comment #12
tim.plunkettLooks much better.
Missing space between if(
Comment #13
JeroenTFixed missing space between if.
Patch attached.
Comment #15
JeroenTComment #16
sdboyer CreditAttribution: sdboyer commenteddiscussed a bit with @tim.plunkett in irc - this is a fine incremental step, but the title was wrong. the patch does not actually remove
drupal_add_html_head_link()
. it only removes direct calls to it. moving things into the render arrays is (probably) a step forward, because it provides us an indirection layer through which we could implement alternate, non-global-static storage. but for now, this simply defers the calls to the global function todrupal_render()
time.but RTBC, because that indirection layer is a win.
we really oughtta start marking up those globals as deprecated, or something like that. not that that ACTUALLY makes things better.
Comment #17
catchYep where we still have direct calls to drupal_render(), which this patch has plenty of, then we don't gain a massive amount. However we could make changes in drupal_render() to make these non global, similar to the 'drupal_render_for_real()' stuff discussed in Prague.
Committed/pushed to 8.x. We'll need a change notice to tell people not to use this function directly any more.
Comment #18
xjmComment #19
effulgentsia CreditAttribution: effulgentsia commentedRetroactively tagging for posterity.
Comment #20
LewisNymanComment #21
LewisNymanMy change notice proposal:
drupal_add_html_head_link() deprecated in favour of #attached['drupal_add_html_head_link']
Instead of calling
drupal_add_html_head_link()
directly, attach the link to a render array.Before
After
Comment #22
star-szrLooks good, the only thing is the examples don't seem to map 1:1. Can we ditch the $rel in the after example and just use 'shortlink', and either simplify the before example OR do the merging of options and adding in
'alias' => TRUE
in the after example?LewisNyman++ :)
Comment #23
LewisNymanOh yeah, so like this? https://drupal.org/node/2160069
Comment #24
codium CreditAttribution: codium commentedUsing array key 'drupal_add_html_head_link' instead of function call which could be hinted in a IDE is a bad move IMHO... What's the motivation? Maybe shorter key name?
Comment #25
star-szr@LewisNyman - yep, that works for me!
@drupality - I think #16 and #17 provide some good background as to why this change was made. The longer term goal if this change is to improve cacheability.
Reverting title, tags, and priority (and marking as fixed) now that the change notice has been written. Thanks @LewisNyman!