From e2a94019b1f194d0101e3a4ef6885bc0c0e362a0 Mon Sep 17 00:00:00 2001 From: epriestley Date: Mon, 24 Apr 2017 09:22:38 -0700 Subject: [PATCH] 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 --- .../autopatches/20170424.user.01.verify.php | 34 +++++++++++++++++++ 1 file changed, 34 insertions(+) create mode 100644 resources/sql/autopatches/20170424.user.01.verify.php diff --git a/resources/sql/autopatches/20170424.user.01.verify.php b/resources/sql/autopatches/20170424.user.01.verify.php new file mode 100644 index 0000000000..d2bbacd3e0 --- /dev/null +++ b/resources/sql/autopatches/20170424.user.01.verify.php @@ -0,0 +1,34 @@ +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())); +} -- 2.51.2