From a3bb9d878f66fbae642b7f1a342745c7602641ea Mon Sep 17 00:00:00 2001 From: Alex Pott <alex.a.pott@googlemail.com> Date: Mon, 11 Jun 2018 18:39:46 +0100 Subject: [PATCH] Issue #2855054 by alexpott, LoMo, wesleydv, Artusamak, gawaksh, xjm: User cancel link doesn't redirect to the homepage --- core/modules/user/src/Controller/UserController.php | 2 +- .../modules/user/tests/src/Functional/UserCancelTest.php | 9 ++++++--- 2 files changed, 7 insertions(+), 4 deletions(-) diff --git a/core/modules/user/src/Controller/UserController.php b/core/modules/user/src/Controller/UserController.php index eba37a9f644d..2bbfe345e73c 100644 --- a/core/modules/user/src/Controller/UserController.php +++ b/core/modules/user/src/Controller/UserController.php @@ -317,7 +317,7 @@ public function confirmCancel(UserInterface $user, $timestamp = 0, $hashed_pass // Since user_cancel() is not invoked via Form API, batch processing // needs to be invoked manually and should redirect to the front page // after completion. - return batch_process(''); + return batch_process('<front>'); } else { $this->messenger()->addError($this->t('You have tried to use an account cancellation link that has expired. Please request a new one using the form below.')); diff --git a/core/modules/user/tests/src/Functional/UserCancelTest.php b/core/modules/user/tests/src/Functional/UserCancelTest.php index 503100c3bcf2..869cd37bdd5a 100644 --- a/core/modules/user/tests/src/Functional/UserCancelTest.php +++ b/core/modules/user/tests/src/Functional/UserCancelTest.php @@ -251,6 +251,12 @@ public function testUserBlockUnpublish() { // Confirm account cancellation request. $this->drupalGet("user/" . $account->id() . "/cancel/confirm/$timestamp/" . user_pass_rehash($account, $timestamp)); + // Confirm that the user was redirected to the front page. + $this->assertSession()->addressEquals(''); + $this->assertSession()->statusCodeEquals(200); + // Confirm that the confirmation message made it through to the end user. + $this->assertRaw(t('%name has been disabled.', ['%name' => $account->getUsername()]), "Confirmation message displayed to user."); + $user_storage->resetCache([$account->id()]); $account = $user_storage->load($account->id()); $this->assertTrue($account->isBlocked(), 'User has been blocked.'); @@ -266,9 +272,6 @@ public function testUserBlockUnpublish() { $storage->resetCache([$comment->id()]); $comment = $storage->load($comment->id()); $this->assertFalse($comment->isPublished(), 'Comment of the user has been unpublished.'); - - // Confirm that the confirmation message made it through to the end user. - $this->assertRaw(t('%name has been disabled.', ['%name' => $account->getUsername()]), "Confirmation message displayed to user."); } /** -- GitLab