1
0
Fork 0
mirror of https://we.phorge.it/source/phorge.git synced 2024-11-30 10:42:41 +01:00
phorge-phorge/resources/sql/autopatches/20170424.user.01.verify.php
epriestley e2a94019b1 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
2017-04-24 10:24:51 -07:00

34 lines
764 B
PHP

<?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()));
}