Problem/Motivation
Since the process layer is being removed from Drupal 8, we need to move the addition of $variables['head'] from the process layer to the preprocess layer. But no variables in preprocess should be rendered, they all need to exist in their renderable state, and should only be rendered later, at the time they are inserted into the templates. Because of this drupal_get_html_head() needs to return a renderable, not rendered output.
Proposed resolution
Code change as follows:
function drupal_get_html_head() {
$elements = drupal_add_html_head();
drupal_alter('html_head', $elements);
return $element;;
}
Remaining tasks
- if necessary, add a equivalent __toString method to the renderable object.
User interface changes
None.
API changes
TBD.
Related Issues
#1843710: Remove template_process_maintenance_page()
#1843704: Remove template_process_html()
#1843650: Remove the process layer (hook_process and hook_process_HOOK)
#2004286: Defer calls to drupal_get_* functions until printed inside a template by adding a RenderWrapper class
| Comment | File | Size | Author |
|---|---|---|---|
| #4 | common-no_drupal_render_in_drupal_get_html_head-1843708-4.patch | 398 bytes | pmelab |
Comments
Comment #0.0
jenlamptonrelated issue
Comment #1
gnugetComment #2
gnugeti checked this issue, and i'm not sure what to do.
Since the preprocess is for renderable variables i'm not sure where should be render the content of the drupal_get_html_head().
I did a quick "grep" into the core and seems to drupal_get_html_head() is mainly used in:
(there are other few places where is used drupal_get_html_head() but my doubts are related with these two templates)
if i make the change suggested in the drupal_get_html_head() function (remove the drupal_render) and put the
$variables['head'] = drupal_get_html_head();at the preprocess where should be rendered the content of the head? directly at thehtml.tpl.php?Comment #3
pmelab commentedWorking on it.
Comment #4
pmelab commentedSimply removed
drupal_render, since html.html.twig and maintenance-page.html.twig handle renderable arrays, it simply works.Comment #6
gnuget#4: common-no_drupal_render_in_drupal_get_html_head-1843708-4.patch queued for re-testing.
Comment #8
joelpittetFYI, if we get #2004286: Defer calls to drupal_get_* functions until printed inside a template by adding a RenderWrapper class in, then this will be render when printed and this will be a non-issue.
Comment #8.0
joelpittetrelated
Comment #9
jenlamptonSo, closing as duplicate of #2004286: Defer calls to drupal_get_* functions until printed inside a template by adding a RenderWrapper class
Comment #9.0
jenlamptonadded wrapper issue to related