mirror of
https://we.phorge.it/source/phorge.git
synced 2024-11-10 00:42:41 +01:00
Migrate accounts to correct user email verification state flag
Summary: Depends on D17785. Fixes T12635. There was a bug where users could verify their primary email without getting the "isEmailVerified" flag set on their accounts. D17785 fixes this bug. This change migrates affected account to fix their state, now that they can't get in trouble any more (hopefully). Test Plan: - Explicitly removed this flag from a bunch of accounts. - Ran migration, saw the accounts get fixed. - Ran migration again (`storage upgrade --apply ...`), saw the accounts not get touched. - We have 117 affected accounts on `secure`, so I'll verify that this fixes them. Reviewers: chad Reviewed By: chad Maniphest Tasks: T12635 Differential Revision: https://secure.phabricator.com/D17786
This commit is contained in:
parent
41d9453ece
commit
e2a94019b1
1 changed files with 34 additions and 0 deletions
34
resources/sql/autopatches/20170424.user.01.verify.php
Normal file
34
resources/sql/autopatches/20170424.user.01.verify.php
Normal file
|
@ -0,0 +1,34 @@
|
|||
<?php
|
||||
|
||||
$table = new PhabricatorUser();
|
||||
$conn = $table->establishConnection('w');
|
||||
|
||||
foreach (new LiskMigrationIterator($table) as $user) {
|
||||
// Ignore users who are verified.
|
||||
if ($user->getIsEmailVerified()) {
|
||||
continue;
|
||||
}
|
||||
|
||||
// Ignore unverified users with missing (rare) or unverified (common)
|
||||
// primary emails: it's correct that their accounts are not verified.
|
||||
$primary = $user->loadPrimaryEmail();
|
||||
if (!$primary) {
|
||||
continue;
|
||||
}
|
||||
|
||||
if (!$primary->getIsVerified()) {
|
||||
continue;
|
||||
}
|
||||
|
||||
queryfx(
|
||||
$conn,
|
||||
'UPDATE %T SET isEmailVerified = 1 WHERE id = %d',
|
||||
$table->getTableName(),
|
||||
$user->getID());
|
||||
|
||||
echo tsprintf(
|
||||
"%s\n",
|
||||
pht(
|
||||
'Corrected account verification state for user "%s".',
|
||||
$user->getUsername()));
|
||||
}
|
Loading…
Reference in a new issue