diff --git a/core/modules/user/src/AccountForm.php b/core/modules/user/src/AccountForm.php index 03e808f978..77c67a0600 100644 --- a/core/modules/user/src/AccountForm.php +++ b/core/modules/user/src/AccountForm.php @@ -392,7 +392,7 @@ public function submitForm(array &$form, FormStateInterface $form_state) { _user_mail_notify('mail_change_notification', $account); // The user's mail address will be updated only after verification. $form_state->setValue('mail', $old_mail); - $this->messenger->addWarning($this->t('Your updated email address needs to be validated. Further instructions have been sent to your new email address.')); + $this->messenger()->addWarning($this->t('Your updated email address needs to be validated. Further instructions have been sent to your new email address.')); } } diff --git a/core/modules/user/src/Controller/MailChangeController.php b/core/modules/user/src/Controller/MailChangeController.php index 3084be4403..7f339e82b7 100644 --- a/core/modules/user/src/Controller/MailChangeController.php +++ b/core/modules/user/src/Controller/MailChangeController.php @@ -33,6 +33,7 @@ public function page(UserInterface $user, $new_mail, $timestamp, $hash) { /** @var \Drupal\Core\Session\AccountProxyInterface $current_user */ $current_user = $this->currentUser(); $request_time = \Drupal::time()->getRequestTime(); + $messenger = $this->messenger(); // Other user is authenticated. if ($current_user->isAuthenticated() && $current_user->id() != $user->id()) { @@ -40,11 +41,11 @@ public function page(UserInterface $user, $new_mail, $timestamp, $hash) { '%user' => $current_user->getAccountName(), ':logout' => Url::fromRoute('user.logout')->toString(), ]; - $this->messenger->addError($this->t('You are currently logged in as %user, and are attempting to confirm an email address change for another account. Please log out and try using the link again.', $arguments)); + $messenger->addError($this->t('You are currently logged in as %user, and are attempting to confirm an email address change for another account. Please log out and try using the link again.', $arguments)); } // The link has expired. elseif ($request_time - $timestamp > $timeout) { - $this->messenger->addError($this->t('You have tried to use an email address change link that has expired. Please visit your account and change your email again.')); + $messenger->addError($this->t('You have tried to use an email address change link that has expired. Please visit your account and change your email again.')); } // The link is valid. elseif ($timestamp <= $request_time && $timestamp >= $user->getLastLoginTime() && Crypt::hashEquals($hash, user_pass_rehash($user, $timestamp, $new_mail))) { @@ -59,12 +60,12 @@ public function page(UserInterface $user, $new_mail, $timestamp, $hash) { $current_user->setAccount($user); } $arguments = ['%mail' => $new_mail]; - $this->messenger->addStatus($this->t('Your email address has been changed to %mail.', $arguments)); + $messenger->addStatus($this->t('Your email address has been changed to %mail.', $arguments)); } // Timestamp from the link is abnormal (in the future) or user registered a // new login in the meantime or the hash is not valid. else { - $this->messenger->addError($this->t('You have tried to use an email address change link that has either been used or is no longer valid. Please visit your account and change your email again.')); + $messenger->addError($this->t('You have tried to use an email address change link that has either been used or is no longer valid. Please visit your account and change your email again.')); } return $this->redirect(''); diff --git a/core/modules/user/tests/src/Functional/Update/UpdateMailChangeTest.php b/core/modules/user/tests/src/Functional/Update/UpdateMailChangeTest.php index b5f8d6ab92..8c05593979 100644 --- a/core/modules/user/tests/src/Functional/Update/UpdateMailChangeTest.php +++ b/core/modules/user/tests/src/Functional/Update/UpdateMailChangeTest.php @@ -9,6 +9,7 @@ * Tests update of user mail change configurations. * * @group user + * @group legacy */ class UpdateMailChangeTest extends UpdatePathTestBase { @@ -17,7 +18,7 @@ class UpdateMailChangeTest extends UpdatePathTestBase { */ protected function setDatabaseDumpFiles() { $this->databaseDumpFiles = [ - __DIR__ . '/../../../../../system/tests/fixtures/update/drupal-8-rc1.bare.standard.php.gz', + __DIR__ . '/../../../../../system/tests/fixtures/update/drupal-8.4.0.bare.standard.php.gz', ]; } @@ -48,7 +49,7 @@ public function testMailChangeUpdate() { $this->assertFalse($user_settings->get('notify.mail_change_notification')); $this->assertFalse($user_settings->get('notify.mail_change_verification')); - $config = Yaml::parse(file_get_contents(__DIR__ . '/../../../config/install/user.mail.yml')); + $config = Yaml::parse(file_get_contents(__DIR__ . '/../../../../config/install/user.mail.yml')); // Check that mail change configurations were set to default values. $this->assertSame($config['mail_change_notification'], $user_mail->get('mail_change_notification'));