Problem/Motivation

This blocks BigPipe for Drupal 8.

#2478483: Introduce placeholders (#lazy_builder) to replace #post_render_cache introduced Renderer::renderPlaceholder(). But kept it protected and off the interface.

First it was public (and on the interface). But then we decided against it, because #2478483-76: Introduce placeholders (#lazy_builder) to replace #post_render_cache:

@Fabianx remarked that the way Renderer::renderPlaceholder() is currently implemented makes it impossible to be used by the BigPipe render strategy, because BigPipe will not be able to merge the bubbleable metadata from the rendered placeholder with that of the rest of the HTML (which makes total sense) — it will e.g. have to load additional assets by including some JS to load those additional assets without loading the already-loaded assets again (i.e. something like Drupal.loadAssetLibrary(), which takes drupalSettings.ajaxPageState into account).

But! That's not something we need to solve here. We can just keep that method protected for now, and make it public (and a public API) as part of #2469431: BigPipe for auth users: first send+render the cheap parts of the page, then the expensive parts. That helps keep the scope of this issue well-defined.

Guess what. #2469431: BigPipe for auth users: first send+render the cheap parts of the page, then the expensive parts is now at that point :) It is in fact blocked on this.

Proposed resolution

  1. Make Renderer::renderPlaceholder() public
  2. Add RendererInterface::renderPlaceholder()

Note this already has extensive test coverage in \Drupal\Tests\Core\Render\RendererPlaceholdersTest.

Remaining tasks

Review.

User interface changes

None.

API changes

None.

Only an API addition: RendererInterface::renderPlaceholder().

Data model changes

None.

Comments

Wim Leers created an issue. See original summary.

wim leers’s picture

Status: Active » Needs review
StatusFileSize
new2.65 KB
wim leers’s picture

Issue tags: +rc target triage
wim leers’s picture

Issue summary: View changes
fabianx’s picture

Status: Needs review » Reviewed & tested by the community

RTBC - Looks great to me!

xjm’s picture

Issue tags: -rc target triage +rc target

So by adding the method to the interface, this is technically a BC break for anyone creating their own implementation of the entire render system... which would be amazing. Ahem. So @alexpott, @effulgentsia, @catch, and I agreed with making this an rc target.

xjm’s picture

Status: Reviewed & tested by the community » Needs work
+++ b/core/lib/Drupal/Core/Render/Renderer.php
@@ -647,6 +631,8 @@ protected function setCurrentRenderContext(RenderContext $context = NULL) {
+   * @see ::renderPlaceholder()

+++ b/core/lib/Drupal/Core/Render/RendererInterface.php
@@ -67,6 +67,24 @@ public function renderRoot(&$elements);
+   * @see ::render()

Note that this format for @see does not work with api.d.o and our standards require a fully namespaced class/method. See:

joelpittet’s picture

Assigned: Unassigned » joelpittet

Fixing #7

joelpittet’s picture

Assigned: joelpittet » Unassigned
Status: Needs work » Reviewed & tested by the community
StatusFileSize
new1.16 KB
new2.19 KB
new3.62 KB
new2.72 KB

This was RTBC, I've addressed the concern in #7 also have two patches. One with the fixes to the other @see :: issues and one withonly the required changed hunks mentioned in #7 Pick one;)

alexpott’s picture

Status: Reviewed & tested by the community » Fixed

Committed 2f5bf09 and pushed to 8.0.x. Thanks!

  • alexpott committed 2f5bf09 on 8.0.x
    Issue #2603786 by joelpittet, Wim Leers, Fabianx: Make Renderer(...
xjm’s picture

Thanks @joelpittet for fixing that up!

wim leers’s picture

Jep, @joelpittet++ :)

Status: Fixed » Closed (fixed)

Automatically closed - issue fixed for 2 weeks with no activity.