Page MenuHomePhabricator

D20913.diff
No OneTemporary

D20913.diff

diff --git a/resources/sql/autopatches/20191114.email.01.phid.sql b/resources/sql/autopatches/20191114.email.01.phid.sql
new file mode 100644
--- /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
--- /dev/null
+++ b/resources/sql/autopatches/20191114.email.02.populate.php
@@ -0,0 +1,18 @@
+<?php
+
+$table = new PhabricatorUserEmail();
+$conn = $table->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
--- a/src/__phutil_library_map__.php
+++ b/src/__phutil_library_map__.php
@@ -4121,6 +4121,8 @@
'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 @@
'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
--- /dev/null
+++ b/src/applications/people/phid/PhabricatorPeopleUserEmailPHIDType.php
@@ -0,0 +1,35 @@
+<?php
+
+final class PhabricatorPeopleUserEmailPHIDType
+ extends PhabricatorPHIDType {
+
+ const TYPECONST = 'EADR';
+
+ public function getTypeName() {
+ return pht('User Email');
+ }
+
+ public function newObject() {
+ return new PhabricatorUserEmail();
+ }
+
+ public function getPHIDTypeApplicationClass() {
+ return 'PhabricatorPeopleApplication';
+ }
+
+ protected function buildQueryForObjects(
+ PhabricatorObjectQuery $query,
+ array $phids) {
+
+ return id(new PhabricatorPeopleUserEmailQuery())
+ ->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
--- /dev/null
+++ b/src/applications/people/query/PhabricatorPeopleUserEmailQuery.php
@@ -0,0 +1,55 @@
+<?php
+
+final class PhabricatorPeopleUserEmailQuery
+ extends PhabricatorCursorPagedPolicyAwareQuery {
+
+ private $ids;
+ private $phids;
+
+ public function withIDs(array $ids) {
+ $this->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
--- a/src/applications/people/storage/PhabricatorUserEmail.php
+++ b/src/applications/people/storage/PhabricatorUserEmail.php
@@ -18,6 +18,7 @@
protected function getConfiguration() {
return array(
+ self::CONFIG_AUX_PHID => true,
self::CONFIG_COLUMN_SCHEMA => array(
'address' => 'sort128',
'isVerified' => 'bool',
@@ -36,6 +37,10 @@
) + parent::getConfiguration();
}
+ public function getPHIDType() {
+ return PhabricatorPeopleUserEmailPHIDType::TYPECONST;
+ }
+
public function getVerificationURI() {
return '/emailverify/'.$this->getVerificationCode().'/';
}

File Metadata

Mime Type
text/plain
Expires
Tue, Mar 25, 7:31 PM (6 d, 2 h ago)
Storage Engine
blob
Storage Format
Encrypted (AES-256-CBC)
Storage Handle
7710221
Default Alt Text
D20913.diff (5 KB)

Event Timeline