From 79f1148dd3a320d5cc922ada4426f78c10fe5521 Mon Sep 17 00:00:00 2001 From: "Donald A. Lobo" Date: Thu, 14 Nov 2013 14:37:59 -0800 Subject: [PATCH] CRM-13760 - improve spec code and cleanup ---------------------------------------- * CRM-13760: "Geocoding failed. Message from Google: OVER_QUERY_LIMIT" should not be fatal http://issues.civicrm.org/jira/browse/CRM-13760 --- CRM/Utils/Address/BatchUpdate.php | 17 +++++++++++++---- CRM/Utils/Geocode/Google.php | 5 ++++- api/v3/Job.php | 6 +++--- 3 files changed, 20 insertions(+), 8 deletions(-) diff --git a/CRM/Utils/Address/BatchUpdate.php b/CRM/Utils/Address/BatchUpdate.php index a6258db8ad..dcc483d19e 100644 --- a/CRM/Utils/Address/BatchUpdate.php +++ b/CRM/Utils/Address/BatchUpdate.php @@ -179,15 +179,24 @@ class CRM_Utils_Address_BatchUpdate { $className = $config->geocodeMethod; $className::format( $params, true ); + + // see if we got a geocode error, in this case we'll trigger a fatal + // CRM-13760 + if ( + isset($params['geo_code_error']) && + $params['geo_code_error'] == 'OVER_QUERY_LIMIT' + ) { + CRM_Core_Error::fatal('Aborting batch geocoding. Hit the over query limit on geocoder.'); + } + array_shift($params); $maxTries--; - } while ((!isset($params['geo_code_1'])) && + } while ( + (!isset($params['geo_code_1']) || $params['geo_code_1'] == 'null') && ($maxTries > 1) ); - if (isset($params['geo_code_1']) && - $params['geo_code_1'] != 'null' - ) { + if (isset($params['geo_code_1']) && $params['geo_code_1'] != 'null') { $totalGeocoded++; $addressParams['geo_code_1'] = $params['geo_code_1']; $addressParams['geo_code_2'] = $params['geo_code_2']; diff --git a/CRM/Utils/Geocode/Google.php b/CRM/Utils/Geocode/Google.php index 835fc24137..aba9acc525 100644 --- a/CRM/Utils/Geocode/Google.php +++ b/CRM/Utils/Geocode/Google.php @@ -147,7 +147,10 @@ class CRM_Utils_Geocode_Google { } } elseif ($xml->status == 'OVER_QUERY_LIMIT') { - CRM_Core_Error::fatal('Geocoding failed. Message from Google: ' . $xml->status); + CRM_Core_Error::debug_var('Geocoding failed. Message from Google: ', (string ) $xml->status); + $values['geo_code_1'] = $values['geo_code_2'] = 'null'; + $values['geo_code_error'] = $xml->status; + return FALSE; } } diff --git a/api/v3/Job.php b/api/v3/Job.php index fdb8fdfd5e..06316253c6 100644 --- a/api/v3/Job.php +++ b/api/v3/Job.php @@ -167,9 +167,9 @@ function civicrm_api3_job_geocode($params) { function _civicrm_api3_job_geocode_spec(&$params) { $params['start'] = array('title' => 'Start Date'); $params['end'] = array('title' => 'End Date'); - $params['geocoding'] = array('title' => 'Is this for GeoCoding? (I think this is a 1,0 field?)'); - $params['parse'] = array('title' => 'Is this for parsing? (I think this is a 1,0 field?)'); - $params['throttle'] = array('title' => 'Throttle? (no idea what you enter in this field)'); + $params['geocoding'] = array('title' => 'Geocode address?'); + $params['parse'] = array('title' => 'Parse street address?'); + $params['throttle'] = array('title' => 'Throttle? if enabled, geocodes at a slow rate'); } /** -- 2.25.1