Problem/Motivation

When rendering an address using the Address Plain field formatter, a PHP warning appears:
"Warning: Illegal offset type in isset or empty in CommerceGuys\Addressing\Subdivision\SubdivisionRepository->hasData() (line 128 of /var/www/drupal-dev/vendor/commerceguys/addressing/src/Subdivision/SubdivisionRepository.php)."
and a PHP notice appears: "Notice: Array to string conversion in CommerceGuys\Addressing\Subdivision\SubdivisionRepository->buildGroup() (line 221 of /var/www/drupal-dev/vendor/commerceguys/addressing/src/Subdivision/SubdivisionRepository.php)."

The messages are only displayed immediately after publish/cache rebuild. Refreshing the page clears the errors until the next cache rebuild.

Steps to Reproduce

  1. Add an Address field and set to display using the Plain formatter.
  2. Select a country that uses the dependentLocality field, e.g. Brazil.
  3. Fill out all address fields and publish.
  4. The aforementioned notice and warning appear.

Proposed resolution

The issue seems to be that $original_values, which is used for $parents, is an array of arrays in the plain formatter, rather than array of strings as in the default formatter. Storing just the contents of $value, not the array with both code and name keys, resolved the issue for me.

Support from Acquia helps fund testing for Drupal Acquia logo

Comments

kmonahan created an issue. See original summary.

  • bojanz committed aad1147 on 8.x-1.x authored by kmonahan
    Issue #2884090 by kmonahan: "Illegal offset" and "Array to string...
bojanz’s picture

Status: Needs review » Fixed

Committed, thanks!

Status: Fixed » Closed (fixed)

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