On Drupal 8.5.0 the geolocation address link stopped working.
I have an Event content-type with 2 fields (geolocation field and address field) on the geolocation address link settings the match setting is correctly set,

Event Location (field_event_location) -> Event Geolocation (field_event_geolocation)

but when saving a node with a correct US address, the geolocation (coordinates) are not being populated at all not even on node save or node edit. this was working on prior versions, so not sure if the latest Drupal core release is causing the issue.

Comments

andres.torres created an issue. See original summary.

thegentleman’s picture

I'm on the previous version of Drupal, have an issue with Webforms, so I haven't updated yet to 8.5.0

However, I'm running into a similar issue where it won't even save. I get back a pretty big PHP Error. I can't create anything new.

Error: Call to undefined method Drupal\address\Element\Address::applyDefaults() in Drupal\geolocation_address_link\AddressToGeo->addressArrayToString() (line 156 of /srv/bindings/5f477fc3653e431ca9511a1c5a26907f/code/modules/geolocation_address_link/src/AddressToGeo.php) #0 /srv/bindings/5f477fc3653e431ca9511a1c5a26907f/code/modules/geolocation_address_link/src/AddressToGeo.php(198): Drupal\geolocation_address_link\AddressToGeo->addressArrayToString(Array) #1 /srv/bindings/5f477fc3653e431ca9511a1c5a26907f/code/modules/geolocation_address_link/geolocation_address_link.module(68): Drupal\geolocation_address_link\AddressToGeo->geocode(Array) #2 [internal function]: geolocation_address_link_entity_presave(Object(Drupal\block_content\Entity\BlockContent)) #3 /srv/bindings/5f477fc3653e431ca9511a1c5a26907f/code/core/lib/Drupal/Core/Extension/ModuleHandler.php(402): call_user_func_array('geolocation_add...', Array) #4 /srv/bindings/5f477fc3653e431ca9511a1c5a26907f/code/core/lib/Drupal/Core/Entity/EntityStorageBase.php(169): Drupal\Core\Extension\ModuleHandler->invokeAll('entity_presave', Array) #5 /srv/bindings/5f477fc3653e431ca9511a1c5a26907f/code/core/lib/Drupal/Core/Entity/ContentEntityStorageBase.php(435): Drupal\Core\Entity\EntityStorageBase->invokeHook('presave', Object(Drupal\block_content\Entity\BlockContent)) #6 /srv/bindings/5f477fc3653e431ca9511a1c5a26907f/code/core/lib/Drupal/Core/Entity/EntityStorageBase.php(435): Drupal\Core\Entity\ContentEntityStorageBase->invokeHook('presave', Object(Drupal\block_content\Entity\BlockContent)) #7 /srv/bindings/5f477fc3653e431ca9511a1c5a26907f/code/core/lib/Drupal/Core/Entity/ContentEntityStorageBase.php(292): Drupal\Core\Entity\EntityStorageBase->doPreSave(Object(Drupal\block_content\Entity\BlockContent)) #8 /srv/bindings/5f477fc3653e431ca9511a1c5a26907f/code/core/lib/Drupal/Core/Entity/EntityStorageBase.php(389): Drupal\Core\Entity\ContentEntityStorageBase->doPreSave(Object(Drupal\block_content\Entity\BlockContent)) #9 /srv/bindings/5f477fc3653e431ca9511a1c5a26907f/code/core/lib/Drupal/Core/Entity/Sql/SqlContentEntityStorage.php(796): Drupal\Core\Entity\EntityStorageBase->save(Object(Drupal\block_content\Entity\BlockContent)) #10 /srv/bindings/5f477fc3653e431ca9511a1c5a26907f/code/core/lib/Drupal/Core/Entity/Entity.php(377): Drupal\Core\Entity\Sql\SqlContentEntityStorage->save(Object(Drupal\block_content\Entity\BlockContent)) #11 /srv/bindings/5f477fc3653e431ca9511a1c5a26907f/code/core/modules/block_content/src/BlockContentForm.php(47): Drupal\Core\Entity\Entity->save() #12 [internal function]: Drupal\block_content\BlockContentForm->save(Array, Object(Drupal\Core\Form\FormState)) #13 /srv/bindings/5f477fc3653e431ca9511a1c5a26907f/code/core/lib/Drupal/Core/Form/FormSubmitter.php(111): call_user_func_array(Array, Array) #14 /srv/bindings/5f477fc3653e431ca9511a1c5a26907f/code/core/lib/Drupal/Core/Form/FormSubmitter.php(51): Drupal\Core\Form\FormSubmitter->executeSubmitHandlers(Array, Object(Drupal\Core\Form\FormState)) #15 /srv/bindings/5f477fc3653e431ca9511a1c5a26907f/code/core/lib/Drupal/Core/Form/FormBuilder.php(585): Drupal\Core\Form\FormSubmitter->doSubmitForm(Array, Object(Drupal\Core\Form\FormState)) #16 /srv/bindings/5f477fc3653e431ca9511a1c5a26907f/code/core/lib/Drupal/Core/Form/FormBuilder.php(314): Drupal\Core\Form\FormBuilder->processForm('block_content_a...', Array, Object(Drupal\Core\Form\FormState)) #17 /srv/bindings/5f477fc3653e431ca9511a1c5a26907f/code/core/lib/Drupal/Core/Entity/EntityFormBuilder.php(48): Drupal\Core\Form\FormBuilder->buildForm('block_content_a...', Object(Drupal\Core\Form\FormState)) #18 /srv/bindings/5f477fc3653e431ca9511a1c5a26907f/code/core/modules/block_content/src/Controller/BlockContentController.php(113): Drupal\Core\Entity\EntityFormBuilder->getForm(Object(Drupal\block_content\Entity\BlockContent)) #19 [internal function]: Drupal\block_content\Controller\BlockContentController->addForm(Object(Drupal\block_content\Entity\BlockContentType), Object(Symfony\Component\HttpFoundation\Request)) #20 /srv/bindings/5f477fc3653e431ca9511a1c5a26907f/code/core/lib/Drupal/Core/EventSubscriber/EarlyRenderingControllerWrapperSubscriber.php(123): call_user_func_array(Array, Array) #21 /srv/bindings/5f477fc3653e431ca9511a1c5a26907f/code/core/lib/Drupal/Core/Render/Renderer.php(582): Drupal\Core\EventSubscriber\EarlyRenderingControllerWrapperSubscriber->Drupal\Core\EventSubscriber\{closure}() #22 /srv/bindings/5f477fc3653e431ca9511a1c5a26907f/code/core/lib/Drupal/Core/EventSubscriber/EarlyRenderingControllerWrapperSubscriber.php(124): Drupal\Core\Render\Renderer->executeInRenderContext(Object(Drupal\Core\Render\RenderContext), Object(Closure)) #23 /srv/bindings/5f477fc3653e431ca9511a1c5a26907f/code/core/lib/Drupal/Core/EventSubscriber/EarlyRenderingControllerWrapperSubscriber.php(97): Drupal\Core\EventSubscriber\EarlyRenderingControllerWrapperSubscriber->wrapControllerExecutionInRenderContext(Array, Array) #24 [internal function]: Drupal\Core\EventSubscriber\EarlyRenderingControllerWrapperSubscriber->Drupal\Core\EventSubscriber\{closure}() #25 /srv/bindings/5f477fc3653e431ca9511a1c5a26907f/code/vendor/symfony/http-kernel/HttpKernel.php(153): call_user_func_array(Object(Closure), Array) #26 /srv/bindings/5f477fc3653e431ca9511a1c5a26907f/code/vendor/symfony/http-kernel/HttpKernel.php(68): Symfony\Component\HttpKernel\HttpKernel->handleRaw(Object(Symfony\Component\HttpFoundation\Request), 1) #27 /srv/bindings/5f477fc3653e431ca9511a1c5a26907f/code/core/lib/Drupal/Core/StackMiddleware/Session.php(57): Symfony\Component\HttpKernel\HttpKernel->handle(Object(Symfony\Component\HttpFoundation\Request), 1, true) #28 /srv/bindings/5f477fc3653e431ca9511a1c5a26907f/code/core/lib/Drupal/Core/StackMiddleware/KernelPreHandle.php(47): Drupal\Core\StackMiddleware\Session->handle(Object(Symfony\Component\HttpFoundation\Request), 1, true) #29 /srv/bindings/5f477fc3653e431ca9511a1c5a26907f/code/core/modules/page_cache/src/StackMiddleware/PageCache.php(99): Drupal\Core\StackMiddleware\KernelPreHandle->handle(Object(Symfony\Component\HttpFoundation\Request), 1, true) #30 /srv/bindings/5f477fc3653e431ca9511a1c5a26907f/code/core/modules/page_cache/src/StackMiddleware/PageCache.php(78): Drupal\page_cache\StackMiddleware\PageCache->pass(Object(Symfony\Component\HttpFoundation\Request), 1, true) #31 /srv/bindings/5f477fc3653e431ca9511a1c5a26907f/code/core/lib/Drupal/Core/StackMiddleware/ReverseProxyMiddleware.php(47): Drupal\page_cache\StackMiddleware\PageCache->handle(Object(Symfony\Component\HttpFoundation\Request), 1, true) #32 /srv/bindings/5f477fc3653e431ca9511a1c5a26907f/code/core/lib/Drupal/Core/StackMiddleware/NegotiationMiddleware.php(50): Drupal\Core\StackMiddleware\ReverseProxyMiddleware->handle(Object(Symfony\Component\HttpFoundation\Request), 1, true) #33 /srv/bindings/5f477fc3653e431ca9511a1c5a26907f/code/vendor/stack/builder/src/Stack/StackedHttpKernel.php(23): Drupal\Core\StackMiddleware\NegotiationMiddleware->handle(Object(Symfony\Component\HttpFoundation\Request), 1, true) #34 /srv/bindings/5f477fc3653e431ca9511a1c5a26907f/code/core/lib/Drupal/Core/DrupalKernel.php(657): Stack\StackedHttpKernel->handle(Object(Symfony\Component\HttpFoundation\Request), 1, true) #35 /srv/bindings/5f477fc3653e431ca9511a1c5a26907f/code/index.php(19): Drupal\Core\DrupalKernel->handle(Object(Symfony\Component\HttpFoundation\Request)) #36 {main}.

marc.groth’s picture

I can confirm that I have the same issue. Stats as follows:

Drupal: 8.5.5
Address: 8.x-1.4
Geolocation: 8.x-1.11
Geolocation Address Link: 8.x-1.1

In my case the lat/lng values are updated however the cos/sin/rad values are not. It seems that those values are only updated upon saving the content a second time. This is because geolocation_address_link_entity_presave() doesn't get to $entity->set($geolocation_field, $values); which effectively wipes out these values (presumably because it only explicitly sets the lat/lng/data values).

Attached is a patch that explicitly sets the cos/sin/rad values so that these are not lost. It also ensures that these values are set the first time the content is saved. They are meant to be set by GeolocationItem::preSave() (in the geolocation module) but that function is not called upon the first save for some reason. That may be part of the problem.

marc.groth’s picture

Status: Active » Needs review
andres.torres’s picture

Status: Needs review » Needs work

On a Drupal 8.6.x install the issue is still present, address link won't generate the LAT/LONG values upon node save or edit.

karens’s picture

The issue #2975883: Fatal Error when creating content - With Address 8.x.1.4 may be a factor here, I just committed a fix for that. Can you confirm if you still have a problem when using the latest dev code?

andres.torres’s picture

Is still an issue, tested on a fresh Drupal install with latest geolocation + geolocation address link with patch.

neelaj82’s picture

I can confirm to this as well. I had successfully wasted hours debugging why my proximity filter was not working and I started looking at the database and noticed that the cos and sin column were empty. It would save if I saved the node twice but not at the first time. This patch worked for me and the node was getting saved with the cos and sin values at the first time.

haasontwerp’s picture

I can confirm this as well using Drupal 8.6.10, and adress field 1.4. Applied this patch: https://www.drupal.org/project/address/issues/2975881 and the patch attached to this issue. Latitude and Longitude are not being saved.

haasontwerp’s picture

  • KarenS committed 169a845 on 8.x-1.x authored by marc.groth
    Issue #2952628 by marc.groth, andres.torres, haasontwerp, TheGentleman,...
karens’s picture

Status: Needs work » Fixed

Makes sense, thanks!

Status: Fixed » Closed (fixed)

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