NameItem::isEmpty() fails with arrays

Created on 27 August 2019, over 5 years ago
Updated 9 February 2023, almost 2 years ago

After RC2 the isEmpty() has been failing with array values.

For some reason however, this seem to be working with live installation with no problem whatsoever, but in (functional) tests, when loading page that tries to print out name field, it will give strlen-error, and the test fails there.

In both cases, the $this->values in isEmpty() contains following

array:7 [▼
  "title" => null
  "given" => "Ad"
  "middle" => null
  "family" => "Min"
  "generational" => null
  "credentials" => null
  "_attributes" => []
]

and as you can see, we've _attributes here (I'm not entirely sure whether it is supposed to be), that does not work properly with the code after parent issue .

In tests, that empty array gives following error

    1)
    Drupal\Tests\my_module\Functional\MyModuleTest::testFoo
    Exception: Warning: strlen() expects parameter 1 to be string, array given
    Drupal\name\Plugin\Field\FieldType\NameItem->isEmpty()() (Line: 127)

Also to note, there was previously hidden bug similar to parent issue, that empty array that was not part of properties was falsely reported as not empty.

🐛 Bug report
Status

Needs work

Version

1.0

Component

Code

Created by

🇫🇮Finland dropa

Live updates comments and jobs are added and updated live.
Sign in to follow issues

Merge Requests

Comments & Activities

Not all content is available!

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

Production build 0.71.5 2024