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
- Add an Address field and set to display using the Plain formatter.
- Select a country that uses the dependentLocality field, e.g. Brazil.
- Fill out all address fields and publish.
- 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.
Comment | File | Size | Author |
---|---|---|---|
fix_plain_addresses_with_dependentLocalities-1.patch | 734 bytes | kmonahan | |
Comments
Comment #3
bojanz CreditAttribution: bojanz at Centarro commentedCommitted, thanks!