Null Children Array in Field Formatter Base

Created on 14 May 2018, almost 7 years ago
Updated 4 February 2023, about 2 years ago

Problem/Motivation

The following error message appears:
Argument 1 passed to Drupal\Core\Render\Element::children() must be of the type array, null given, called in /var/www/news-linux.byu.edu/web/core/lib/Drupal/Core/Field/FormatterBase.php on line 84 in Drupal\Core\Render\Element::children() (line 71 of core/lib/Drupal/Core/Render/Element.php).

Proposed resolution

Add a null check before passing the elements variable.

πŸ› Bug report
Status

Needs work

Version

9.5

Component
FieldΒ  β†’

Last updated 1 day ago

Created by

πŸ‡ΊπŸ‡ΈUnited States blakemorgan

Live updates comments and jobs are added and updated live.
  • Needs tests

    The change is currently missing an automated test that fails when run with the original code, and succeeds when the bug has been fixed.

  • Needs issue summary update

    Issue summaries save everyone time if they are kept up-to-date. See Update issue summary task instructions.

Sign in to follow issues

Comments & Activities

Not all content is available!

It's likely this issue predates Contrib.social: some issue and comment data are missing.

  • πŸ‡ΊπŸ‡ΈUnited States smustgrave

    This issue is being reviewed by the kind folks in Slack, #needs-review-queue-initiative. We are working to keep the size of Needs Review queue [2700+ issues] to around 400 (1 month or less), following Review a patch or merge request β†’ as a guide.

    Previously tagged for tests and issue summary in #4 which still needs to happen for this issue to move forward.

  • πŸ‡ͺπŸ‡ΈSpain akalam

    Re-rolled against core 10.2

  • Status changed to Closed: works as designed about 2 months ago
  • πŸ‡ͺπŸ‡ΈSpain vidorado LogroΓ±o (La Rioja)

    I believe we shouldn't suppress errors caused by a contrib or custom FieldFormatter. The return type of FieldFormatterInterface::viewElements() is explicitly defined as array, so no formatter should return NULL.

    I would close this as "Works as designed."

  • πŸ‡¨πŸ‡ΎCyprus alex.bukach

    Agree @vidorado, the proper fix is to find the formatter(s) that return NULL and fix them.

Production build 0.71.5 2024