Zip code range search only supports numeric zip codes so don't try and search if...
authorMatthew Wire <mjw@mjwconsult.co.uk>
Sat, 6 Jun 2020 11:46:07 +0000 (12:46 +0100)
committerMatthew Wire <mjw@mjwconsult.co.uk>
Sat, 6 Jun 2020 11:46:07 +0000 (12:46 +0100)
CRM/Contact/Form/Search/Custom/ZipCodeRange.php

index 594462f0e1118218a3afe79d970e384cb8fa2cf7..98887e8f2e4cc573b8b3b3c768d4df66afc21714 100644 (file)
@@ -146,16 +146,22 @@ LEFT JOIN civicrm_email   email   ON ( email.contact_id = contact_a.id AND
    * @return string
    */
   public function where($includeContactIDs = FALSE) {
-    $params = [];
-
     $low = CRM_Utils_Array::value('postal_code_low',
       $this->_formValues
     );
     $high = CRM_Utils_Array::value('postal_code_high',
       $this->_formValues
     );
+    $errorMessage = NULL;
     if ($low == NULL || $high == NULL) {
-      CRM_Core_Error::statusBounce(ts('Please provide start and end postal codes'),
+      $errorMessage = ts('Please provide start and end postal codes.');
+    }
+
+    if (!is_numeric($low) || !is_numeric($high)) {
+      $errorMessage = ts('This search only supports numeric postal codes.');
+    }
+    if ($errorMessage) {
+      CRM_Core_Error::statusBounce($errorMessage,
         CRM_Utils_System::url('civicrm/contact/search/custom',
           "reset=1&csid={$this->_formValues['customSearchID']}",
           FALSE, NULL, FALSE, TRUE