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.

  1. While loading config, We are loading plugins_options which were not saved during module installation.
  2. 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 .

CommentFileSizeAuthor
#9 PluginOptions-2949313-9.patch278 byteskunalkursija

Comments

kunal.kursija created an issue. See original summary.

  • itamair committed 7cdb533 on 8.x-2.x
    Added default geocoder.settings config install plugins_options
    Fix Issue...
itamair’s picture

The new dev defines default geocoder config install plugins_options ... thus solving this issue.

itamair’s picture

Status: Active » Needs review
pol’s picture

Hello,

This is not how this should be fixed.

We need to add a condition when this is not an array and transform it accordingly.

  • itamair committed d695d16 on 8.x-2.x
    removed code to face/handle possible JSON format of previous beta...
itamair’s picture

The 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.

  • itamair committed 67cb59a on 8.x-2.x
    Changed default geocoder.settings config install plugins_options to...
kunalkursija’s picture

StatusFileSize
new278 bytes

@itamair - Yes this empty array solves the issue. Just a minor thing, What we have committed is plugins_options: {} However, it should be plugins_options: { } with 2 spaces in between braces.

Adding Patch for same.

pol’s picture

Hi,

Indeed, it's how its done in D8. I wasn't aware of this, thanks!

I will amend this commit.

  • Pol committed 8cde7ec on 8.x-2.x
    Issue #2949313: Fix YAML syntax.
    
pol’s picture

Status: Needs review » Fixed

Thanks all, closing the issue.

Status: Fixed » Closed (fixed)

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