When the module is installed for first time, The initial config of the module only saves following in geocoder.settings.yml
cache: true
Now in geocoder_field_entity_presave() function, There are two things.
- While loading config, We are loading
plugins_optionswhich were not saved during module installation. - The loaded config call
$geocoder_plugins_options = $geocoder_config->get('plugins_options');expects the config to be array, But it will be empty since it's not saved in beginning.
Hence the below code in geocoder_field_entity_presave() is causing a fatal error where empty is passed instead of array.
$address_collection = \Drupal::service('geocoder')->geocode($value['value'], $geocoder['plugins'], $geocoder_plugins_options);
Note: This error will be reproducible only when you apply the patch mentioned here - https://www.drupal.org/project/geocoder/issues/2949301#comment-12506349 .
| Comment | File | Size | Author |
|---|---|---|---|
| #9 | PluginOptions-2949313-9.patch | 278 bytes | kunalkursija |
Comments
Comment #3
itamair commentedThe new dev defines default geocoder config install plugins_options ... thus solving this issue.
Comment #4
itamair commentedComment #5
polHello,
This is not how this should be fixed.
We need to add a condition when this is not an array and transform it accordingly.
Comment #7
itamair commentedThe last refactoring just committed into dev exactly adds a variable cast to array to all $plugins options definition, that will intercept also any possible NULL value.
Comment #9
kunalkursija commented@itamair - Yes this empty array solves the issue. Just a minor thing, What we have committed is
plugins_options: {}However, it should beplugins_options: { }with 2 spaces in between braces.Adding Patch for same.
Comment #10
polHi,
Indeed, it's how its done in D8. I wasn't aware of this, thanks!
I will amend this commit.
Comment #12
polThanks all, closing the issue.