Skip to content

Drupal 10.3 Element children from User Error to throw an exception breaks any non render array (but still array) output #462

@DiegoPino

Description

@DiegoPino

What?

Drupal! Devs (to make tests pass and use the new PHP UNIT 10 stuff) made a large breaking change. Any Array output via {{ data.i_am_an_array }} will no longer show a user error on screen but will basically kill the page.

See https://git.drupalcode.org/project/drupal/-/commit/3d645c1b3c

The reason is someone decided to override in Drupal Core the normal Twig Escape Extension (the default)

Which in turn calls this code with a silly message (no, not handled!!!)

  // This is a normal render array, which is safe by definition, with
  // special simple cases already handled.
  
  // Early return if this element was pre-rendered (no need to re-render).
    if (isset($arg['#printed']) && $arg['#printed'] == TRUE && isset($arg['#markup']) && strlen($arg['#markup']) > 0) {
      return $arg['#markup'];
    }
    $arg['#printed'] = FALSE;
    return $this->renderer->render($arg);

And $this->renderer->render($arg);

and renderer::render will call
Renderer.php:462, Drupal\Core\Render\Renderer->doRender()
Element.php:97, Drupal\Core\Render\Element::children()

Throwing an exception nobody is catching and not only failing to render a single piece, but the whole page

I need to think how to override for our use case this. There is a LOT of code happening and too many layers.

Metadata

Metadata

Assignees

Labels

Drupal 10Upgrade economyTwig ExtensionMake those flowers reach the sunexternal bugIt is not us, it is them

Type

No type

Projects

No projects

Relationships

None yet

Development

No branches or pull requests

Issue actions