hook_civicrm_geocoderFormat does not alter address components
Steps to repro:
- Create an extension named
geocoderformat
containing this hook implementation:
function geocoderformat_civicrm_geocoderFormat($geoProvider, &$values, $xml) {
$values['county_id'] = 2;
}
- Install clean civicrm 5.49.5, enable this extension, and configure geocoding (eg set "Administer => Mapping => Geocoding Provider" to "Google").
- For any contact, save a new address in California, being sure to leave the county field empty, and observe that the county is forced to "Contra Costa".
- Install clean civicrm 5.51.1 (I think 5.51.0 will also demonstrate the problem), enable this extension, and configure geocoding.
- For any contact, save a new address in California, being sure to leave the county field empty, and observe that the county is not altered.
Best guess as to the cause:
Changes in cb695d3e (pinging @colemanw) caused CRM_Utils_Hook::geocoderFormat('Google', $values, $xml)
to be called in a context in which $values
is never used.
Suggested solution:
The CRM_Utils_Geocode_Google::makeRequest()
method should receive $values
as a parameter-by-reference.
I'm planning to submit a simple PR along those lines.
Edited by totten