DB Error when Create User Record
Overview
When I try to create a user with "Create user Record", the CMS user is correctly created, but a new Civicrm user is added.
- Check that eamil address is uniq
- And don't exist on CMS side
- In Civicrm Contact view, click Actions/Create user record, fill password and click Add
- Got an error "Fatal error: DB error".
- CMS user is created
- but another Civicrm user is created vith the same email
- CMS error :
Expected behaviour
No new user created and CMS userID should be associated to existing Civicrm
Environment information
- Civicrm 5.51.2 (but same behavior in previous versions)
- PHP 7.4.19
- Drupal 9.4.5
Comments
In /vendor/civicrm/civicrm-core/CRM/Core/BAO/UFMatch.php, line 250, ll the information on the Civicrm account is deleted, and only the email address is present. In the continuation of the treatment, it is not possible any more to find the account thus a new account is created in /vendor/civicrm/civicrm-coreCRM/CoreBAO/CMSUser.php
Proposal
Replace in /vendor/civicrm/civicrm-core/CRM/Core/BAO/UFMatch.php, line 250 $params = ['email' => $primary_email]; by $params['email'] = $primary_email;