Merge pull request #17771 from mattwire/ufmatch_validemail
[civicrm-core.git] / CRM / Core / BAO / UFMatch.php
index b7dd9b2c80187275e9022d123fe3c6f4d9038b07..d4900271542f9a25168d6ebe6f23c0bf3d19224b 100644 (file)
@@ -171,12 +171,6 @@ class CRM_Core_BAO_UFMatch extends CRM_Core_DAO_UFMatch {
    */
   public static function &synchronizeUFMatch(&$user, $userKey, $uniqId, $uf, $status = NULL, $ctype = NULL, $isLogin = FALSE) {
     $config = CRM_Core_Config::singleton();
-
-    if (!CRM_Utils_Rule::email($uniqId)) {
-      $retVal = $status ? NULL : FALSE;
-      return $retVal;
-    }
-
     $newContact = FALSE;
 
     // make sure that a contact id exists for this user id
@@ -191,6 +185,12 @@ class CRM_Core_BAO_UFMatch extends CRM_Core_DAO_UFMatch {
       if (!empty($_POST) && !$isLogin) {
         $params = $_POST;
         $params['email'] = $uniqId;
+        // dev/core#1858 Ensure that if we have a contactID parameter which is set in the Create user Record contact task form
+        // That this contacID value is passed through as the contact_id to the get duplicate contacts function. This is necessary because for Drupal 8 this function gets invoked
+        // Before the civicrm_uf_match record is added where as in D7 it isn't called until the user tries to actually login.
+        if (!empty($params['contactID'])) {
+          $params['contact_id'] = $params['contactID'];
+        }
 
         $ids = CRM_Contact_BAO_Contact::getDuplicateContacts($params, 'Individual', 'Unsupervised', [], FALSE);