diff --git a/resources/sql/autopatches/20191114.email.01.phid.sql b/resources/sql/autopatches/20191114.email.01.phid.sql new file mode 100644 index 0000000000..3851d6e0ec --- /dev/null +++ b/resources/sql/autopatches/20191114.email.01.phid.sql @@ -0,0 +1,2 @@ +ALTER TABLE {$NAMESPACE}_user.user_email + ADD phid VARBINARY(64) NOT NULL; diff --git a/resources/sql/autopatches/20191114.email.02.populate.php b/resources/sql/autopatches/20191114.email.02.populate.php new file mode 100644 index 0000000000..96ef13ea58 --- /dev/null +++ b/resources/sql/autopatches/20191114.email.02.populate.php @@ -0,0 +1,18 @@ +establishConnection('w'); + +$iterator = new LiskRawMigrationIterator($conn, $table->getTableName()); +foreach ($iterator as $row) { + $phid = $row['phid']; + + if (!strlen($phid)) { + queryfx( + $conn, + 'UPDATE %R SET phid = %s WHERE id = %d', + $table, + $table->generatePHID(), + $row['id']); + } +} diff --git a/src/__phutil_library_map__.php b/src/__phutil_library_map__.php index ffb824f177..30627e8b59 100644 --- a/src/__phutil_library_map__.php +++ b/src/__phutil_library_map__.php @@ -4121,6 +4121,8 @@ phutil_register_library_map(array( 'PhabricatorPeopleTasksProfileMenuItem' => 'applications/people/menuitem/PhabricatorPeopleTasksProfileMenuItem.php', 'PhabricatorPeopleTestDataGenerator' => 'applications/people/lipsum/PhabricatorPeopleTestDataGenerator.php', 'PhabricatorPeopleTransactionQuery' => 'applications/people/query/PhabricatorPeopleTransactionQuery.php', + 'PhabricatorPeopleUserEmailPHIDType' => 'applications/people/phid/PhabricatorPeopleUserEmailPHIDType.php', + 'PhabricatorPeopleUserEmailQuery' => 'applications/people/query/PhabricatorPeopleUserEmailQuery.php', 'PhabricatorPeopleUserFunctionDatasource' => 'applications/people/typeahead/PhabricatorPeopleUserFunctionDatasource.php', 'PhabricatorPeopleUserPHIDType' => 'applications/people/phid/PhabricatorPeopleUserPHIDType.php', 'PhabricatorPeopleUsernameMailEngine' => 'applications/people/mail/PhabricatorPeopleUsernameMailEngine.php', @@ -10617,6 +10619,8 @@ phutil_register_library_map(array( 'PhabricatorPeopleTasksProfileMenuItem' => 'PhabricatorProfileMenuItem', 'PhabricatorPeopleTestDataGenerator' => 'PhabricatorTestDataGenerator', 'PhabricatorPeopleTransactionQuery' => 'PhabricatorApplicationTransactionQuery', + 'PhabricatorPeopleUserEmailPHIDType' => 'PhabricatorPHIDType', + 'PhabricatorPeopleUserEmailQuery' => 'PhabricatorCursorPagedPolicyAwareQuery', 'PhabricatorPeopleUserFunctionDatasource' => 'PhabricatorTypeaheadCompositeDatasource', 'PhabricatorPeopleUserPHIDType' => 'PhabricatorPHIDType', 'PhabricatorPeopleUsernameMailEngine' => 'PhabricatorPeopleMailEngine', diff --git a/src/applications/people/phid/PhabricatorPeopleUserEmailPHIDType.php b/src/applications/people/phid/PhabricatorPeopleUserEmailPHIDType.php new file mode 100644 index 0000000000..0aadc149f6 --- /dev/null +++ b/src/applications/people/phid/PhabricatorPeopleUserEmailPHIDType.php @@ -0,0 +1,35 @@ +withPHIDs($phids); + } + + public function loadHandles( + PhabricatorHandleQuery $query, + array $handles, + array $objects) { + return null; + } + +} diff --git a/src/applications/people/query/PhabricatorPeopleUserEmailQuery.php b/src/applications/people/query/PhabricatorPeopleUserEmailQuery.php new file mode 100644 index 0000000000..f0330f34f9 --- /dev/null +++ b/src/applications/people/query/PhabricatorPeopleUserEmailQuery.php @@ -0,0 +1,55 @@ +ids = $ids; + return $this; + } + + public function withPHIDs(array $phids) { + $this->phids = $phids; + return $this; + } + + public function newResultObject() { + return new PhabricatorUserEmail(); + } + + protected function loadPage() { + return $this->loadStandardPage($this->newResultObject()); + } + + protected function getPrimaryTableAlias() { + return 'email'; + } + + protected function buildWhereClauseParts(AphrontDatabaseConnection $conn) { + $where = parent::buildWhereClauseParts($conn); + + if ($this->ids !== null) { + $where[] = qsprintf( + $conn, + 'email.id IN (%Ld)', + $this->ids); + } + + if ($this->phids !== null) { + $where[] = qsprintf( + $conn, + 'email.phid IN (%Ls)', + $this->phids); + } + + return $where; + } + + public function getQueryApplicationClass() { + return 'PhabricatorPeopleApplication'; + } + +} diff --git a/src/applications/people/storage/PhabricatorUserEmail.php b/src/applications/people/storage/PhabricatorUserEmail.php index f626e8f133..cf2c61dc03 100644 --- a/src/applications/people/storage/PhabricatorUserEmail.php +++ b/src/applications/people/storage/PhabricatorUserEmail.php @@ -18,6 +18,7 @@ final class PhabricatorUserEmail protected function getConfiguration() { return array( + self::CONFIG_AUX_PHID => true, self::CONFIG_COLUMN_SCHEMA => array( 'address' => 'sort128', 'isVerified' => 'bool', @@ -36,6 +37,10 @@ final class PhabricatorUserEmail ) + parent::getConfiguration(); } + public function getPHIDType() { + return PhabricatorPeopleUserEmailPHIDType::TYPECONST; + } + public function getVerificationURI() { return '/emailverify/'.$this->getVerificationCode().'/'; }