From e13b709c6970a0f13034ba4d70541806506e84e3 Mon Sep 17 00:00:00 2001 From: Ollie <43674967+outdooracorn@users.noreply.github.com> Date: Wed, 12 Nov 2025 11:39:28 +0000 Subject: [PATCH] Anonymize user email in disable command There is a unique constraint on the user email column, meaning an empty string won't work for disabling subsequent users Bug: T409908 --- app/Console/Commands/User/Disable.php | 2 +- tests/Commands/User/DisableTest.php | 9 ++++++--- 2 files changed, 7 insertions(+), 4 deletions(-) diff --git a/app/Console/Commands/User/Disable.php b/app/Console/Commands/User/Disable.php index d82237fa8..d35633c32 100644 --- a/app/Console/Commands/User/Disable.php +++ b/app/Console/Commands/User/Disable.php @@ -51,7 +51,7 @@ public function handle(): int { } $userId = $user->id; - $user->email = ''; + $user->email = uniqid() . '@disabled-user.wikibase.cloud'; $user->password = random_bytes(10); $user->verified = false; diff --git a/tests/Commands/User/DisableTest.php b/tests/Commands/User/DisableTest.php index 1599a0e39..fff1064ce 100644 --- a/tests/Commands/User/DisableTest.php +++ b/tests/Commands/User/DisableTest.php @@ -23,7 +23,6 @@ private function createUser($email) { public function testSuccess() { $oldUser = $this->createUser(self::EMAIL); - $oldUserId = $oldUser->id; $this->artisan('wbs-user:disable', [ @@ -31,11 +30,15 @@ public function testSuccess() { ] )->assertExitCode(0); - $newUser = User::firstWhere('id', $oldUserId); + $newUser = User::firstWhere('id', $oldUser->id); $this->assertSame($oldUser->id, $newUser->id); - $this->assertSame($newUser->email, ''); + $this->assertMatchesRegularExpression( + '/^[0-9A-Za-z]+@disabled-user.wikibase.cloud$/', + $newUser->email + ); $this->assertFalse($newUser->hasVerifiedEmail()); + $this->assertNotSame($oldUser->password, $newUser->password); } public function testUserNotFound() {