jenkins-bot has submitted this change and it was merged.

Change subject: Fill in missing city and state from US zip code
......................................................................


Fill in missing city and state from US zip code

Bug: T86239
Change-Id: Iea001290d30059c94e63e5179a0e489ccfe5c8ae
---
M sites/all/modules/wmf_civicrm/wmf_civicrm.module
1 file changed, 12 insertions(+), 3 deletions(-)

Approvals:
  XenoRyet: Looks good to me, approved
  jenkins-bot: Verified



diff --git a/sites/all/modules/wmf_civicrm/wmf_civicrm.module 
b/sites/all/modules/wmf_civicrm/wmf_civicrm.module
index 21bfae5..4bfced4 100644
--- a/sites/all/modules/wmf_civicrm/wmf_civicrm.module
+++ b/sites/all/modules/wmf_civicrm/wmf_civicrm.module
@@ -2720,9 +2720,11 @@
                                $address['country_id'] == $usId &&
                                !empty( $address['postal_code'] )
                        ) {
-                               $sql = 'SELECT latitude, longitude, timezone
-                                       FROM wmf_zip_geo
-                                       WHERE zip = %1';
+                               $sql = "SELECT city, s.id AS state_id, 
latitude, longitude, timezone
+                                       FROM wmf_zip_geo g
+                                       JOIN civicrm_state_province s ON 
s.abbreviation = g.state
+                                           AND s.country_id = $usId
+                                       WHERE zip = %1";
 
                                $result = CRM_Core_DAO::executeQuery(
                                        $sql,
@@ -2737,6 +2739,13 @@
                                                'geo_code_2' => 
$result->longitude,
                                                'timezone' => $result->timezone,
                                        );
+                                       // Only overwrite city and state if 
empty
+                                       if ( empty( $address['city'] ) ) {
+                                               $geoData['city'] = 
$result->city;
+                                       }
+                                       if ( $address['state_province_id'] == 
'null' ) {
+                                               $geoData['state_province_id'] = 
$result->state_id;
+                                       }
                                }
                        }
                        if ( empty( $geoData ) && $op == 'edit' ) {

-- 
To view, visit https://gerrit.wikimedia.org/r/319480
To unsubscribe, visit https://gerrit.wikimedia.org/r/settings

Gerrit-MessageType: merged
Gerrit-Change-Id: Iea001290d30059c94e63e5179a0e489ccfe5c8ae
Gerrit-PatchSet: 1
Gerrit-Project: wikimedia/fundraising/crm
Gerrit-Branch: master
Gerrit-Owner: Ejegg <[email protected]>
Gerrit-Reviewer: Awight <[email protected]>
Gerrit-Reviewer: Cdentinger <[email protected]>
Gerrit-Reviewer: XenoRyet <[email protected]>
Gerrit-Reviewer: jenkins-bot <>

_______________________________________________
MediaWiki-commits mailing list
[email protected]
https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits

Reply via email to