Support for Drupal 7 is ending on 5 January 2025—it’s time to migrate to Drupal 10! Learn about the many benefits of Drupal 10 and find migration tools in our resource center.
Just found this and the issue that introduced it #859466: Error when iterating over EntityListWrapper properties without data.
foreach ($this->wrapper()->foo->getIterator() as $data) {
$values[] = $data->value()->name;
}
$data-value() will throw an exception since the item is empty - so you have to count() the field or similar prior to the foreach().
I'd expect to just get an empty iterator here instead so the foreach is a no-op.