Drupal 8 - Using Create User Record action on a contact with no email is too quiet. Also CRM_Core_Session::setStatus is sometimes ignored.
Followup to #91 (closed) and https://github.com/civicrm/civicrm-core/pull/17771
It won't create the user but because of the way it fails the logged in user doesn't see an error, it just reloads the contact view page. If you look in drupal watchdog though it will say CRM_Core_Exception: is not of type String in CRM_Core_DAO::composeQuery() (line 1660 of ...\CRM\Core\DAO.php)
.
What's happening is hook_user_insert is trying to do stuff and it properly fails, but because of two compounding bugs you don't see the usual bounce message or fatal error screen.
One is that there are certain situations where if you call CRM_Core_Session::setStatus() and leave the message blank and only set a title, it won't show the popup.
The other is that the form doesn't look at the return value of the user create call, so even if the popup was working it would say success.
So two things:
Avoid the exception. I'm still looking closer where this should go. To be in line with https://github.com/civicrm/civicrm-drupal-8/pull/42 there could also be a non-form-related user-validation attached somewhere to handle blank emails when a drupal user is created programmatically.
Audit uses of setStatus to see if they are silently failing elsewhere, and see if fixing info.tpl makes them work. It looks like there are two others:
- On batch update for contacts, when you save it's supposed to display a popup message.
- Ditto when you delete a campaign survey.
- There is also when you delete or restore a case activity, but this follows a different path and is javascript only and doesn't use info.tpl.