Hi!

I discovered (and apparently also fixed) a bug in this module.

It seems to be due to a change in the signature of the constructor of PostalLabelFormatter in the Address module.

Here's the stacktrace:

[25-Jan-2019 14:05:16 America/New_York] TypeError: Argument 4 passed to CommerceGuys\Addressing\Formatter\PostalLabelFormatter::__construct() must be of the type array, string given, called in \modules\contrib\geolocation_address_link\src\AddressToGeo.php on line 144 in \vendor\commerceguys\addressing\src\Formatter\PostalLabelFormatter.php on line 50 #0 \modules\contrib\geolocation_address_link\src\AddressToGeo.php(144): CommerceGuys\Addressing\Formatter\PostalLabelFormatter->__construct(Object(Drupal\address\Repository\AddressFormatRepository), Object(Drupal\address\Repository\CountryRepository), Object(Drupal\address\Repository\SubdivisionRepository), 'US', 'en')
#1 \modules\contrib\geolocation_address_link\src\AddressToGeo.php(92): Drupal\geolocation_address_link\AddressToGeo->setFormatter()
#2 \core\lib\Drupal\Component\DependencyInjection\Container.php(274): Drupal\geolocation_address_link\AddressToGeo->__construct(Object(Drupal\geolocation\GeolocationCore), Object(Drupal\address\Repository\AddressFormatRepository), Object(Drupal\address\Repository\CountryRepository), Object(Drupal\address\Repository\SubdivisionRepository))
#3 \core\lib\Drupal\Component\DependencyInjection\Container.php(171): Drupal\Component\DependencyInjection\Container->createService(Array, 'geolocation_add...')
#4 \core\lib\Drupal.php(158): Drupal\Component\DependencyInjection\Container->get('geolocation_add...')
#5 \modules\contrib\geolocation_address_link\geolocation_address_link.module(33): Drupal::service('geolocation_add...')
#6 [internal function]: geolocation_address_link_entity_presave(Object(Drupal\field\Entity\FieldStorageConfig), 'field_storage_c...')
#7 \core\lib\Drupal\Core\Extension\ModuleHandler.php(403): call_user_func_array('geolocation_add...', Array)
#8 \core\lib\Drupal\Core\Config\Entity\ConfigEntityStorage.php(349): Drupal\Core\Extension\ModuleHandler->invokeAll('entity_presave', Array)
#9 \core\lib\Drupal\Core\Entity\EntityStorageBase.php(472): Drupal\Core\Config\Entity\ConfigEntityStorage->invokeHook('presave', Object(Drupal\field\Entity\FieldStorageConfig))
#10 \core\lib\Drupal\Core\Entity\EntityStorageBase.php(426): Drupal\Core\Entity\EntityStorageBase->doPreSave(Object(Drupal\field\Entity\FieldStorageConfig))
#11 \core\lib\Drupal\Core\Config\Entity\ConfigEntityStorage.php(263): Drupal\Core\Entity\EntityStorageBase->save(Object(Drupal\field\Entity\FieldStorageConfig))
#12 \core\lib\Drupal\Core\Entity\Entity.php(390): Drupal\Core\Config\Entity\ConfigEntityStorage->save(Object(Drupal\field\Entity\FieldStorageConfig))
#13 \core\lib\Drupal\Core\Config\Entity\ConfigEntityBase.php(632): Drupal\Core\Entity\Entity->save()
#14 \core\modules\field_ui\src\Form\FieldStorageAddForm.php(352): Drupal\Core\Config\Entity\ConfigEntityBase->save()
#15 [internal function]: Drupal\field_ui\Form\FieldStorageAddForm->submitForm(Array, Object(Drupal\Core\Form\FormState))
#16 \core\lib\Drupal\Core\Form\FormSubmitter.php(111): call_user_func_array(Array, Array)
#17 \core\lib\Drupal\Core\Form\FormSubmitter.php(51): Drupal\Core\Form\FormSubmitter->executeSubmitHandlers(Array, Object(Drupal\Core\Form\FormState))
#18 \core\lib\Drupal\Core\Form\FormBuilder.php(589): Drupal\Core\Form\FormSubmitter->doSubmitForm(Array, Object(Drupal\Core\Form\FormState))
#19 \core\lib\Drupal\Core\Form\FormBuilder.php(318): Drupal\Core\Form\FormBuilder->processForm('field_ui_field_...', Array, Object(Drupal\Core\Form\FormState))
#20 \core\lib\Drupal\Core\Controller\FormController.php(93): Drupal\Core\Form\FormBuilder->buildForm('field_ui_field_...', Object(Drupal\Core\Form\FormState))
#21 [internal function]: Drupal\Core\Controller\FormController->getContentResult(Object(Symfony\Component\HttpFoundation\Request), Object(Drupal\Core\Routing\RouteMatch))
#22 \core\lib\Drupal\Core\EventSubscriber\EarlyRenderingControllerWrapperSubscriber.php(123): call_user_func_array(Array, Array)
#23 \core\lib\Drupal\Core\Render\Renderer.php(582): Drupal\Core\EventSubscriber\EarlyRenderingControllerWrapperSubscriber->Drupal\Core\EventSubscriber\{closure}()
#24 \core\lib\Drupal\Core\EventSubscriber\EarlyRenderingControllerWrapperSubscriber.php(124): Drupal\Core\Render\Renderer->executeInRenderContext(Object(Drupal\Core\Render\RenderContext), Object(Closure))
#25 \core\lib\Drupal\Core\EventSubscriber\EarlyRenderingControllerWrapperSubscriber.php(97): Drupal\Core\EventSubscriber\EarlyRenderingControllerWrapperSubscriber->wrapControllerExecutionInRenderContext(Array, Array)
#26 \vendor\symfony\http-kernel\HttpKernel.php(151): Drupal\Core\EventSubscriber\EarlyRenderingControllerWrapperSubscriber->Drupal\Core\EventSubscriber\{closure}()
#27 \vendor\symfony\http-kernel\HttpKernel.php(68): Symfony\Component\HttpKernel\HttpKernel->handleRaw(Object(Symfony\Component\HttpFoundation\Request), 1)
#28 \core\lib\Drupal\Core\StackMiddleware\Session.php(57): Symfony\Component\HttpKernel\HttpKernel->handle(Object(Symfony\Component\HttpFoundation\Request), 1, true)
#29 \core\lib\Drupal\Core\StackMiddleware\KernelPreHandle.php(47): Drupal\Core\StackMiddleware\Session->handle(Object(Symfony\Component\HttpFoundation\Request), 1, true)
#30 \core\modules\page_cache\src\StackMiddleware\PageCache.php(99): Drupal\Core\StackMiddleware\KernelPreHandle->handle(Object(Symfony\Component\HttpFoundation\Request), 1, true)
#31 \core\modules\page_cache\src\StackMiddleware\PageCache.php(78): Drupal\page_cache\StackMiddleware\PageCache->pass(Object(Symfony\Component\HttpFoundation\Request), 1, true)
#32 \modules\contrib\services\src\StackMiddleware\FormatSetter.php(44): Drupal\page_cache\StackMiddleware\PageCache->handle(Object(Symfony\Component\HttpFoundation\Request), 1, true)
#33 \core\lib\Drupal\Core\StackMiddleware\ReverseProxyMiddleware.php(47): Drupal\services\StackMiddleware\FormatSetter->handle(Object(Symfony\Component\HttpFoundation\Request), 1, true)
#34 \core\lib\Drupal\Core\StackMiddleware\NegotiationMiddleware.php(52): Drupal\Core\StackMiddleware\ReverseProxyMiddleware->handle(Object(Symfony\Component\HttpFoundation\Request), 1, true)
#35 \vendor\stack\builder\src\Stack\StackedHttpKernel.php(23): Drupal\Core\StackMiddleware\NegotiationMiddleware->handle(Object(Symfony\Component\HttpFoundation\Request), 1, true)
#36 \core\lib\Drupal\Core\DrupalKernel.php(665): Stack\StackedHttpKernel->handle(Object(Symfony\Component\HttpFoundation\Request), 1, true)
#37 \index.php(19): Drupal\Core\DrupalKernel->handle(Object(Symfony\Component\HttpFoundation\Request))
#38 {main}

Unfortunately, at the time I am writing this, I don't really know how to create a patch, but here's my fix for line 144 of file src\AddressToGeo.php :

$this->formatter = new PostalLabelFormatter($this->addressFormatRepository, $this->countryRepository, $this->subdivisionRepository,  ['locale' => $this->formatLanguage, 'origin_country' => $this->formatCountry]);

I don't currently have a Google maps API key to test, but afterwards I was able to link my 2 fields from the configuration page.

Comments

ncg777 created an issue. See original summary.

scotwith1t’s picture

Version: 8.x-1.1 » 8.x-1.x-dev
Status: Active » Fixed

Looks like this has already been fixed in the latest dev. Thanks! https://cgit.drupalcode.org/geolocation_address_link/commit/src/AddressT...

scotwith1t’s picture

Status: Fixed » Closed (duplicate)
Related issues: +#2975883: Fatal Error when creating content - With Address 8.x.1.4