diff --git a/core/modules/user/src/AccountForm.php b/core/modules/user/src/AccountForm.php index 14272a2..2b33726 100644 --- a/core/modules/user/src/AccountForm.php +++ b/core/modules/user/src/AccountForm.php @@ -391,15 +391,13 @@ public function submitForm(array &$form, FormStateInterface $form_state) { // Send a verification to the new email address. $account_cloned = clone $account; $account_cloned->setEmail($new_mail); - if (_user_mail_notify('mail_change_verification', $account_cloned)) { + if (_user_mail_notify('mail_change_verification', $account_cloned) !== NULL) { // Send notification email to the old email address. _user_mail_notify('mail_change_notification', $account); + // The user's mail address will be updated only after verification. + $form_state->setValue('mail', $old_mail); + drupal_set_message($this->t('Your new email address needs to be validated. Further instructions have been sent to your new email address.'), 'warning'); } - - // The user's mail address will be updated only after verification. - $form_state->setValue('mail', $old_mail); - - drupal_set_message($this->t('Your new email address needs to be validated. Further instructions have been sent to your new email address.'), 'warning'); } parent::submitForm($form, $form_state); diff --git a/core/modules/user/user.module b/core/modules/user/user.module index 7b0f1a1..79a137e 100644 --- a/core/modules/user/user.module +++ b/core/modules/user/user.module @@ -1199,11 +1199,13 @@ function user_role_revoke_permissions($rid, array $permissions = array()) { * (optional) Language code to use for the notification, overriding account * language. * - * @return array - * An array containing various information about the message. - * See \Drupal\Core\Mail\MailManagerInterface::mail() for details. + * @return array|null + * An array containing various information about the message, as they are + * returned by \Drupal\Core\Mail\MailManagerInterface::mail(), or NULL if the + * notifications for the required operation are disabled. * * @see user_mail_tokens() + * @see \Drupal\Core\Mail\MailManagerInterface::mail() */ function _user_mail_notify($op, $account, $langcode = NULL) { if (\Drupal::config('user.settings')->get('notify.' . $op)) {