Problem/Motivation
Ajax error thrown and spinner just "hangs" without any other error indication when selecting Geolocation Formatter - Map without any Map provider.
Steps to reproduce
Install the Geolocation module but don't install any map providers. Then go to Manage display on the field and choose Geolocation Formatter - Map. The spinner comes on and a 500 error is thrown.
Error: Typed property Drupal\geolocation\Plugin\Field\FieldFormatter\GeolocationMapFormatterBase::$mapProvider must not be accessed before initialization in Drupal\geolocation\Plugin\Field\FieldFormatter\GeolocationMapFormatterBase->settingsSummary() (line 328 of /var/www/vhosts/staging.whalesafari.is/httpdocs/web/modules/contrib/geolocation/src/Plugin/Field/FieldFormatter/GeolocationMapFormatterBase.php).
Proposed resolution
Although a PEBKAC error, this needs to be handled more gracefully. The problem is that the summary function assumes that there is a $mapProvider initialised, but if there are no map providers installed, then it will not be initialised, hence the error.
Something like this would result in graceful display (Line 328 of GeolocationMapFormatterBase.php)
return (!isset($this->mapProvider))
? $summary
: array_replace_recursive($summary, $this->mapProvider->getSettingsSummary($settings['map_provider_settings']));Remaining tasks
User interface changes
The summary should display something like: "No map providers installed, please go "here" to install at least one.
API changes
None
Data model changes
None
Issue fork geolocation-3447082
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
Comment #2
akhil_01 commentedComment #6
christianadamski commented