Problem/Motivation

PHP Fatal error on node page when using the Map Formatter on an Address field.

TypeError: Cannot access offset of type string on string in Drupal\geolocation\Plugin\Field\FieldFormatter\GeolocationMapFormatterBase->getMapObjects() (line
                                                  432 of modules/contrib/geolocation/src/Plugin/Field/FieldFormatter/GeolocationMapFormatterBase.php).

Steps to reproduce

Add an address field on a content type.
Set the field display as Geolocation Formatter - Map
Create a node of that content type and add a valid address
View the page it will result in a WSOD

Proposed resolution

Looks like AddressFieldProvider's getLocationFromItem method is not returning an array of render arrays. Instead it's returning a flat render array. The geolocation map formatter expects this function to return a list of render arrays.

Command icon Show commands

Start within a Git clone of the project using the version control instructions.

Or, if you do not have SSH keys set up on git.drupalcode.org:

Comments

hablat created an issue. See original summary.

christianadamski made their first commit to this issue’s fork.

christianadamski’s picture

Status: Active » Fixed

Fair enough. Minimal alter to appease PHPCS.

Thanks!

Now that this issue is closed, review the contribution record.

As a contributor, attribute any organization that helped you, or if you volunteered your own time.

Maintainers, credit people who helped resolve this issue.

Status: Fixed » Closed (fixed)

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