<?php
/*
+--------------------------------------------------------------------+
- | CiviCRM version 4.4 |
+ | CiviCRM version 4.5 |
+--------------------------------------------------------------------+
- | Copyright CiviCRM LLC (c) 2004-2013 |
+ | Copyright CiviCRM LLC (c) 2004-2014 |
+--------------------------------------------------------------------+
| This file is a part of CiviCRM. |
| |
// do check for geocoding.
$processGeocode = FALSE;
if (empty($config->geocodeMethod)) {
- if ($this->geocoding == 'true') {
+ if (CRM_Utils_String::strtobool($this->geocoding) === TRUE) {
$this->returnMessages[] = ts('Error: You need to set a mapping provider under Administer > System Settings > Mapping and Geocoding');
$this->returnError = 1;
$this->returnResult();
else {
$processGeocode = TRUE;
// user might want to over-ride.
- if ($this->geocoding == 'false') {
+ if (CRM_Utils_String::strtobool($this->geocoding) === FALSE) {
$processGeocode = FALSE;
}
}
);
$parseStreetAddress = FALSE;
if (!$parseAddress) {
- if ($this->parse == 'true') {
+ if (CRM_Utils_String::strtobool($this->parse) === TRUE) {
$this->returnMessages[] = ts('Error: You need to enable Street Address Parsing under Administer > Localization > Address Settings.');
$this->returnError = 1;
return $this->returnResult();
else {
$parseStreetAddress = TRUE;
// user might want to over-ride.
- if ($this->parse == 'false') {
+ if (CRM_Utils_String::strtobool($this->parse) === FALSE) {
$parseStreetAddress = FALSE;
}
}
function processContacts(&$config, $processGeocode, $parseStreetAddress) {
// build where clause.
$clause = array('( c.id = a.contact_id )');
+ $params = array();
if ($this->start) {
- $clause[] = "( c.id >= $this->start )";
+ $clause[] = "( c.id >= %1 )";
+ $params[1] = array($this->start, 'Integer');
}
if ($this->end) {
- $clause[] = "( c.id <= $this->end )";
+ $clause[] = "( c.id <= %2 )";
+ $params[2] = array($this->end, 'Integer');
}
if ($processGeocode) {
$totalGeocoded = $totalAddresses = $totalAddressParsed = 0;
- $dao = CRM_Core_DAO::executeQuery($query, CRM_Core_DAO::$_nullArray);
-
+ $dao = CRM_Core_DAO::executeQuery($query, $params);
if ($processGeocode) {
require_once (str_replace('_', DIRECTORY_SEPARATOR, $config->geocodeMethod) . '.php');
}
$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'];
$success = TRUE;
// consider address is automatically parseable,
// when we should found street_number and street_name
- if (!CRM_Utils_Array::value('street_name', $parsedFields) ||
- !CRM_Utils_Array::value('street_number', $parsedFields)
- ) {
+ if (empty($parsedFields['street_name']) || empty($parsedFields['street_number'])) {
$success = FALSE;
}