Closed ghost closed 7 years ago
Hi, thanks for contributing! Could you please provide steps to reproduce the problem so I can see it in action? Sometimes it's helpful to bring things out of the abstract.
Hi!
Oops, forget about this patch. I just realized that CRM_Geofill_Parser_Google->getAddressProperty
was already parsing arrays or strings properly.
I was led on the wrong track because initially it did not work for me:
What I did
What I expected
For the geo_code values of contacts to be populated (by the Google geocoder), along with the missing country, state_province, city, postal code, etc (by com.ginkgostreet.geofill).
What happened
The geo_code values were populated along with the postal code, but the city fields were never updated.
What I found
CRM_Utils_Address_BatchUpdate->processContacts
from CiviCRM core will disregard most fields being sent back from the geocoder (and hook). I created issue #6 to highlight this problem and created an issue/PR with CiviCRM (CRM-19977) to see if it could be resolved.
I originally thought that the issue was that CRM_Geofill_Parser_Google->getAddressProperty
(from com.ginkgostreet.geofill) would fail when the geodata results would contain an array for the address component type.
My mistake, sorry. But there is still a problem with CiviCRM in handling the updated fields this extension is sending back.
Hi,
It seems Google has changed their geodata results and sometimes the address component's type is an array instead of simply being a string. This causes the parsing function to fail to catch all the address components returned.
Submitted a PR for a simple fix that worked for me.