Issue #3620623: Builder overwrites #post_render, dropping core's entity render recursion protection

LayoutParagraphsBuilder::buildComponent() replaced #post_render instead of appending to it, dropping the EntityViewBuilder::unsetRecursiveRenderProtection() callback that Drupal 11.4 pairs with its #pre_render recursion tracker. Every component the builder rendered leaked its recursion key for the rest of the request, so the next render of that paragraph was aborted as a false positive and rendered empty.

Changes

  • Append the callback rather than replace the array.
  • layout_paragraphs_double_render_test: a test module whose paragraph.html.twig assigns content|render to a variable before printing content.regions, the common theme idiom that renders every nested component twice.
  • RecursiveRenderProtectionTest: puts a text component inside a one-column section and loads the host node's edit form. Without the fix the second render is aborted and the resulting PHP warning fails the test.

Verification

Drupal 11.4.5, PHP 8.3.

  • phpunit tests/src/Functional/ - 2 tests, 25 assertions, OK. The new test errors without the fix with Recursive rendering attempt aborted for paragraph:entity_id:2:2:....
  • phpcs --standard=Drupal,DrupalPractice - clean.
  • phpstan - no errors.

The same line is in 2.0.x, 2.1.x and 2.2.x. Reproduced and fixed on a live 11.4.5 site running 2.1.3 with Mercury Editor: 12 warnings per page load before, none after.

Closes #3620623

Merge request reports

Loading
Loading