A direct call to Renderer::render(), at least when RenderItemTest::testPreprocessIndexItems() runs throws:-

\LogicException When called outside of a render context. (i.e. outside of a renderRoot(), renderPlain() or executeInRenderContext() call.)

Call is made in RenderedItem::preprocessIndexItems(). Guessing swapping for ::renderPlain() is going to be appropriate for a value being preprocessed for the index. Patch to follow.

Support from Acquia helps fund testing for Drupal Acquia logo

Comments

ekes’s picture

Clears exception and this tests passes.

See: #2529036: Form validate() to formValidate(), leads to fatal error on index creation for clearing other test fails.

drunken monkey’s picture

Status: Active » Fixed

The documentation could be in Chinese for all I understand of it, but if it fixes the issue, sure. Committed.
Thanks a lot for the patch!

  • drunken monkey committed c1655c6 on 8.x-1.x authored by ekes
    Issue #2529990 by ekes: Fixed illegal direct call to Renderer::render().
    

Status: Fixed » Closed (fixed)

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

bjaxelsen’s picture

Status: Closed (fixed) » Needs review
FileSize
612 bytes

Using the renderPlain() method causes a problem when you have references entities. I have a Paragraphs field and the contents of this field does not get rendered. I think it works to use renderRoot() instead.

drunken monkey’s picture

Status: Needs review » Closed (fixed)

Are you completely sure about that? There is nothing in the documentation that suggests this and looking at the code I also see almost no possible way that the two could have different results.
Finally, it seems calling renderRoot() will throw an exception when called from inside another renderRoot() call, so this will potentially also fail completely in some situations.

Please debug more to find out a) if there really is a difference, and why/how, and b) what a better fix would be. Then please create a new issue.