province abbreviation patch - issue 724 5.53.0-fsf 5.53.0-fsf-michael-attempt-0
authorIan Kelling <iank@fsf.org>
Thu, 11 Nov 2021 02:05:07 +0000 (21:05 -0500)
committerMichael McMahon <michael@fsf.org>
Tue, 27 Sep 2022 21:05:22 +0000 (17:05 -0400)
CRM/Contact/BAO/Query.php

index 20a918c3b8e2be1a370ef97e625c983c7f8f9bcc..a42a4032d68875223a84b0de6fb5c9848b19104f 100644 (file)
@@ -6071,7 +6071,16 @@ AND   displayRelType.is_active = 1
           }
         }
         elseif ($value['pseudoField'] == 'state_province_abbreviation') {
-          $dao->$key = CRM_Core_PseudoConstant::stateProvinceAbbreviation($val);
+               // old bad code:
+//          $dao->$key = CRM_Core_PseudoConstant::stateProvinceAbbreviation($val);
+         // iank: Return abbreviation if its a province from a country that uses abbreviations,
+         // otherwise return the name of the province.
+         // https://lab.civicrm.org/dev/core/issues/724
+         if (is_numeric(CRM_Core_PseudoConstant::stateProvinceAbbreviation($val))) {
+           $dao->$key = CRM_Core_PseudoConstant::stateProvince($val);
+         } else {
+           $dao->$key = CRM_Core_PseudoConstant::stateProvinceAbbreviation($val);
+         }
         }
         // @todo handle this in the section above for pseudoconstants.
         elseif (in_array($value['pseudoField'], ['participant_role_id', 'participant_role'])) {