Follow-up from #2167039: Regression: page cache tags broken, also: some routes incorrectly use _controller -> No page object in template variables -> Fatal in seven_preprocess_page().

Problem/Motivation

As reported by @Crell on #2167039-70: Regression: page cache tags broken, also: some routes incorrectly use _controller -> No page object in template variables -> Fatal in seven_preprocess_page(), drupalRender() and drupalRenderCollectCacheTags() are in HtmlControllerBase, though they don't belong to.

Proposed resolution

Move them to own renderer or service to inject them to HTMLPageController.

Remaining tasks

Issue patch.
Test

User interface changes

N/A

API changes

N/A

Originally reported by Crell

Comments

dawehner’s picture

This was certainly just a freakout from crell :)

If we manage to put drupal_render/drupal_render_collect_cache_tags into a service we will do it, otherwise the current pattern is the way to move forward.

wim leers’s picture

Status: Active » Closed (works as designed)
Issue tags: -Spark, -sprint

Closing as per #1.

edurenye’s picture

Status: Closed (works as designed) » Active

There is a reference to this issue in AjaxRenderer, at least we should remove that reference.

dawehner’s picture

+1

edurenye’s picture

Status: Active » Needs review
StatusFileSize
new603 bytes

Done.
Should we replace the deprecated method too?

dawehner’s picture

I think the right fix is to actually convert drupal_render_root() to the renderer service.

wim leers’s picture

Status: Needs review » Needs work

For #6.

edurenye’s picture

Version: 8.0.x-dev » 8.6.x-dev
Status: Needs work » Needs review
StatusFileSize
new596 bytes
new679 bytes

Fixed.

wim leers’s picture

Status: Needs review » Needs work
+++ b/core/lib/Drupal/Core/Render/MainContent/AjaxRenderer.php
@@ -76,11 +76,9 @@ public function renderResponse(array $main_content, Request $request, RouteMatch
-    return drupal_render_root($elements);
+    return \Drupal::service('renderer')->renderRoot($elements);

Thanks, this is a good step forward!

It's not quite done yet though: we want to have the '@renderer' service injected into this service (so that it is passed into this class' constructor). Then we can remove drupalRenderRoot() altogether, and just call $this->renderer->renderRoot()!

leon kessler’s picture

Status: Needs work » Needs review
StatusFileSize
new2.99 KB

Here's a patch that injects the renderer service, and also removes the drupalRenderRoot() method.

Status: Needs review » Needs work

The last submitted patch, 10: 2182149-10.patch, failed testing. View results

dawehner’s picture

Is there a reason we cannot close this issue as duplicate of #2818677: Replace usages of deprecated method drupal_render_root()?

Version: 8.6.x-dev » 8.7.x-dev

Drupal 8.6.0-alpha1 will be released the week of July 16, 2018, which means new developments and disruptive changes should now be targeted against the 8.7.x-dev branch. For more information see the Drupal 8 minor version schedule and the Allowed changes during the Drupal 8 release cycle.

Version: 8.7.x-dev » 8.8.x-dev

Drupal 8.7.0-alpha1 will be released the week of March 11, 2019, which means new developments and disruptive changes should now be targeted against the 8.8.x-dev branch. For more information see the Drupal 8 minor version schedule and the Allowed changes during the Drupal 8 release cycle.

berdir’s picture

Status: Needs work » Closed (duplicate)

> Is there a reason we cannot close this issue as duplicate of #2818677: Replace usages of deprecated method drupal_render_root()?

No reason.