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.

#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

Comments

jenlampton’s picture

Issue summary: View changes

related issue

gnuget’s picture

Assigned: Unassigned » gnuget
gnuget’s picture

i 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:

template_process_html
template_process_maintenance_page

(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 the html.tpl.php?

pmelab’s picture

Working on it.

pmelab’s picture

Status: Active » Needs review
StatusFileSize
new398 bytes

Simply removed drupal_render, since html.html.twig and maintenance-page.html.twig handle renderable arrays, it simply works.

Status: Needs review » Needs work
Issue tags: -Twig, -theme system cleanup

The last submitted patch, common-no_drupal_render_in_drupal_get_html_head-1843708-4.patch, failed testing.

gnuget’s picture

Status: Needs work » Needs review

Status: Needs review » Needs work
Issue tags: +Twig, +theme system cleanup

The last submitted patch, common-no_drupal_render_in_drupal_get_html_head-1843708-4.patch, failed testing.

joelpittet’s picture

Assigned: gnuget » Unassigned

FYI, 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.

joelpittet’s picture

Issue summary: View changes

related

jenlampton’s picture

jenlampton’s picture

Issue summary: View changes

added wrapper issue to related