From db3a0c90bbc2b20952f871d568e5bccba41583aa Mon Sep 17 00:00:00 2001 From: epriestley Date: Wed, 24 Jul 2013 14:12:39 -0700 Subject: [PATCH] Use Application PHIDs for XUSR Summary: Ref T2715. XUSR -> apps Test Plan: `phid.query` Reviewers: btrahan Reviewed By: btrahan CC: aran Maniphest Tasks: T2715 Differential Revision: https://secure.phabricator.com/D6558 --- src/__phutil_library_map__.php | 2 + .../query/PhabricatorExternalAccountQuery.php | 4 -- .../query/PhabricatorMetaMTAActorQuery.php | 5 +- .../PhabricatorPeoplePHIDTypeExternal.php | 46 +++++++++++++++++++ .../storage/PhabricatorExternalAccount.php | 2 +- .../phid/PhabricatorPHIDConstants.php | 1 - .../handle/PhabricatorObjectHandleData.php | 24 ---------- 7 files changed, 52 insertions(+), 32 deletions(-) create mode 100644 src/applications/people/phid/PhabricatorPeoplePHIDTypeExternal.php diff --git a/src/__phutil_library_map__.php b/src/__phutil_library_map__.php index f55ae3d51f..85bddae9a4 100644 --- a/src/__phutil_library_map__.php +++ b/src/__phutil_library_map__.php @@ -1366,6 +1366,7 @@ phutil_register_library_map(array( 'PhabricatorPeopleLdapController' => 'applications/people/controller/PhabricatorPeopleLdapController.php', 'PhabricatorPeopleListController' => 'applications/people/controller/PhabricatorPeopleListController.php', 'PhabricatorPeopleLogsController' => 'applications/people/controller/PhabricatorPeopleLogsController.php', + 'PhabricatorPeoplePHIDTypeExternal' => 'applications/people/phid/PhabricatorPeoplePHIDTypeExternal.php', 'PhabricatorPeopleProfileController' => 'applications/people/controller/PhabricatorPeopleProfileController.php', 'PhabricatorPeopleProfileEditController' => 'applications/people/controller/PhabricatorPeopleProfileEditController.php', 'PhabricatorPeopleProfilePictureController' => 'applications/people/controller/PhabricatorPeopleProfilePictureController.php', @@ -3387,6 +3388,7 @@ phutil_register_library_map(array( 1 => 'PhabricatorApplicationSearchResultsControllerInterface', ), 'PhabricatorPeopleLogsController' => 'PhabricatorPeopleController', + 'PhabricatorPeoplePHIDTypeExternal' => 'PhabricatorPHIDType', 'PhabricatorPeopleProfileController' => 'PhabricatorPeopleController', 'PhabricatorPeopleProfileEditController' => 'PhabricatorPeopleController', 'PhabricatorPeopleProfilePictureController' => 'PhabricatorPeopleController', diff --git a/src/applications/auth/query/PhabricatorExternalAccountQuery.php b/src/applications/auth/query/PhabricatorExternalAccountQuery.php index 8d40963708..b8cb53cc2c 100644 --- a/src/applications/auth/query/PhabricatorExternalAccountQuery.php +++ b/src/applications/auth/query/PhabricatorExternalAccountQuery.php @@ -68,10 +68,6 @@ final class PhabricatorExternalAccountQuery } public function willFilterPage(array $accounts) { - if (!$accounts) { - return $accounts; - } - if ($this->needImages) { $file_phids = mpull($accounts, 'getProfileImagePHID'); $file_phids = array_filter($file_phids); diff --git a/src/applications/metamta/query/PhabricatorMetaMTAActorQuery.php b/src/applications/metamta/query/PhabricatorMetaMTAActorQuery.php index eae0a34a7c..237b4736b3 100644 --- a/src/applications/metamta/query/PhabricatorMetaMTAActorQuery.php +++ b/src/applications/metamta/query/PhabricatorMetaMTAActorQuery.php @@ -28,14 +28,15 @@ final class PhabricatorMetaMTAActorQuery extends PhabricatorQuery { $actors[$phid] = id(new PhabricatorMetaMTAActor())->setPHID($phid); } - // TODO: Move this to PhabricatorPHIDType. + // TODO: Move this to PhabricatorPHIDType, or the objects, or some + // interface. foreach ($type_map as $type => $phids) { switch ($type) { case PhabricatorPHIDConstants::PHID_TYPE_USER: $this->loadUserActors($actors, $phids); break; - case PhabricatorPHIDConstants::PHID_TYPE_XUSR: + case PhabricatorPeoplePHIDTypeExternal::TYPECONST: $this->loadExternalUserActors($actors, $phids); break; case PhabricatorMailingListPHIDTypeList::TYPECONST: diff --git a/src/applications/people/phid/PhabricatorPeoplePHIDTypeExternal.php b/src/applications/people/phid/PhabricatorPeoplePHIDTypeExternal.php new file mode 100644 index 0000000000..4332260034 --- /dev/null +++ b/src/applications/people/phid/PhabricatorPeoplePHIDTypeExternal.php @@ -0,0 +1,46 @@ +setViewer($query->getViewer()) + ->withPHIDs($phids) + ->execute(); + } + + public function loadHandles( + PhabricatorHandleQuery $query, + array $handles, + array $objects) { + + foreach ($handles as $phid => $handle) { + $account = $objects[$phid]; + + $display_name = $account->getDisplayName(); + $handle->setName($display_name); + } + } + + public function canLoadNamedObject($name) { + return false; + } + +} diff --git a/src/applications/people/storage/PhabricatorExternalAccount.php b/src/applications/people/storage/PhabricatorExternalAccount.php index 558485a316..bb860503cc 100644 --- a/src/applications/people/storage/PhabricatorExternalAccount.php +++ b/src/applications/people/storage/PhabricatorExternalAccount.php @@ -33,7 +33,7 @@ final class PhabricatorExternalAccount extends PhabricatorUserDAO public function generatePHID() { return PhabricatorPHID::generateNewPHID( - PhabricatorPHIDConstants::PHID_TYPE_XUSR); + PhabricatorPeoplePHIDTypeExternal::TYPECONST); } public function getConfiguration() { diff --git a/src/applications/phid/PhabricatorPHIDConstants.php b/src/applications/phid/PhabricatorPHIDConstants.php index f0ec72187f..bbba0c95a8 100644 --- a/src/applications/phid/PhabricatorPHIDConstants.php +++ b/src/applications/phid/PhabricatorPHIDConstants.php @@ -30,7 +30,6 @@ final class PhabricatorPHIDConstants { const PHID_TYPE_XACT = 'XACT'; const PHID_TYPE_XCMT = 'XCMT'; - const PHID_TYPE_XUSR = 'XUSR'; const PHID_TYPE_BOOK = 'BOOK'; const PHID_TYPE_ATOM = 'ATOM'; diff --git a/src/applications/phid/handle/PhabricatorObjectHandleData.php b/src/applications/phid/handle/PhabricatorObjectHandleData.php index 10d85f3c5d..b4387efa0b 100644 --- a/src/applications/phid/handle/PhabricatorObjectHandleData.php +++ b/src/applications/phid/handle/PhabricatorObjectHandleData.php @@ -114,13 +114,6 @@ final class PhabricatorObjectHandleData { ->execute(); return mpull($posts, null, 'getPHID'); - case PhabricatorPHIDConstants::PHID_TYPE_XUSR: - $xusr_dao = new PhabricatorExternalAccount(); - $xusrs = $xusr_dao->loadAllWhere( - 'phid in (%Ls)', - $phids); - return mpull($xusrs, null, 'getPHID'); - case PhabricatorPHIDConstants::PHID_TYPE_LEGD: $legds = id(new LegalpadDocumentQuery()) ->needDocumentBodies(true) @@ -327,23 +320,6 @@ final class PhabricatorObjectHandleData { } break; - case PhabricatorPHIDConstants::PHID_TYPE_XUSR: - foreach ($phids as $phid) { - $handle = new PhabricatorObjectHandle(); - $handle->setPHID($phid); - $handle->setType($type); - if (empty($objects[$phid])) { - $handle->setName('Unknown Display Name'); - } else { - $xusr = $objects[$phid]; - $display_name = $xusr->getDisplayName(); - $handle->setName($display_name); - $handle->setFullName($display_name.' (External User)'); - } - $handles[$phid] = $handle; - } - break; - case PhabricatorPHIDConstants::PHID_TYPE_LEGD: foreach ($phids as $phid) { $handle = new PhabricatorObjectHandle();