1
0
Fork 0
mirror of https://we.phorge.it/source/phorge.git synced 2024-11-30 10:42:41 +01:00

Kill PhabricatorObjectDataHandle

Summary: Ref T603. Killing this class is cool because the classes that replace it are policy-aware. Tried to keep my wits about me as I did this and fixed a few random things along the way. (Ones I remember right now are pulling a query outside of a foreach loop in Releeph and fixing the text in UIExample to note that the ace of hearts if "a powerful" card and not the "most powerful" card (Q of spades gets that honor IMO))

Test Plan: tested the first few changes (execute, executeOne X handle, object) then got real mechanical / careful with the other changes.

Reviewers: epriestley

Reviewed By: epriestley

CC: Korvin, aran, FacebookPOC

Maniphest Tasks: T603

Differential Revision: https://secure.phabricator.com/D6941
This commit is contained in:
Bob Trahan 2013-09-11 12:27:28 -07:00
parent 07b8becfc6
commit b902005bed
92 changed files with 336 additions and 364 deletions

View file

@ -1376,7 +1376,6 @@ phutil_register_library_map(array(
'PhabricatorOAuthServerTokenController' => 'applications/oauthserver/controller/PhabricatorOAuthServerTokenController.php', 'PhabricatorOAuthServerTokenController' => 'applications/oauthserver/controller/PhabricatorOAuthServerTokenController.php',
'PhabricatorObjectHandle' => 'applications/phid/PhabricatorObjectHandle.php', 'PhabricatorObjectHandle' => 'applications/phid/PhabricatorObjectHandle.php',
'PhabricatorObjectHandleConstants' => 'applications/phid/handle/const/PhabricatorObjectHandleConstants.php', 'PhabricatorObjectHandleConstants' => 'applications/phid/handle/const/PhabricatorObjectHandleConstants.php',
'PhabricatorObjectHandleData' => 'applications/phid/handle/PhabricatorObjectHandleData.php',
'PhabricatorObjectHandleStatus' => 'applications/phid/handle/const/PhabricatorObjectHandleStatus.php', 'PhabricatorObjectHandleStatus' => 'applications/phid/handle/const/PhabricatorObjectHandleStatus.php',
'PhabricatorObjectListView' => 'view/control/PhabricatorObjectListView.php', 'PhabricatorObjectListView' => 'view/control/PhabricatorObjectListView.php',
'PhabricatorObjectMailReceiver' => 'applications/metamta/receiver/PhabricatorObjectMailReceiver.php', 'PhabricatorObjectMailReceiver' => 'applications/metamta/receiver/PhabricatorObjectMailReceiver.php',

View file

@ -381,9 +381,10 @@ final class PhabricatorAuditCommentEditor extends PhabricatorEditor {
$commit_phid = $commit->getPHID(); $commit_phid = $commit->getPHID();
$phids = array($commit_phid); $phids = array($commit_phid);
$handles = id(new PhabricatorObjectHandleData($phids)) $handles = id(new PhabricatorHandleQuery())
->setViewer($this->getActor()) ->setViewer($this->getActor())
->loadHandles(); ->withPHIDs($phids)
->execute();
$handle = $handles[$commit_phid]; $handle = $handles[$commit_phid];
$name = $handle->getName(); $name = $handle->getName();
@ -446,9 +447,10 @@ final class PhabricatorAuditCommentEditor extends PhabricatorEditor {
$email_cc = array_keys($email_cc); $email_cc = array_keys($email_cc);
$phids = array_merge($email_to, $email_cc); $phids = array_merge($email_to, $email_cc);
$handles = id(new PhabricatorObjectHandleData($phids)) $handles = id(new PhabricatorHandleQuery())
->setViewer($this->getActor()) ->setViewer($this->getActor())
->loadHandles(); ->withPHIDs($phids)
->execute();
// NOTE: Always set $is_new to false, because the "first" mail in the // NOTE: Always set $is_new to false, because the "first" mail in the
// thread is the Herald notification of the commit. // thread is the Herald notification of the commit.

View file

@ -267,9 +267,10 @@ abstract class PhabricatorController extends AphrontController {
} }
protected function loadViewerHandles(array $phids) { protected function loadViewerHandles(array $phids) {
return id(new PhabricatorObjectHandleData($phids)) return id(new PhabricatorHandleQuery())
->setViewer($this->getRequest()->getUser()) ->setViewer($this->getRequest()->getUser())
->loadHandles(); ->withPHIDs($phids)
->execute();
} }

View file

@ -51,9 +51,10 @@ final class ConpherenceNewController extends ConpherenceController {
$participant_handles = array(); $participant_handles = array();
if ($participants) { if ($participants) {
$handles = id(new PhabricatorObjectHandleData($participants)) $handles = id(new PhabricatorHandleQuery())
->setViewer($user) ->setViewer($user)
->loadHandles(); ->withPHIDs($participants)
->execute();
$participant_handles = mpull($handles, 'getFullName', 'getPHID'); $participant_handles = mpull($handles, 'getFullName', 'getPHID');
} }

View file

@ -152,9 +152,10 @@ final class ConpherenceThreadQuery
$conpherence->$method(); $conpherence->$method();
} }
$flat_phids = array_mergev($handle_phids); $flat_phids = array_mergev($handle_phids);
$handles = id(new PhabricatorObjectHandleData($flat_phids)) $handles = id(new PhabricatorHandleQuery())
->setViewer($this->getViewer()) ->setViewer($this->getViewer())
->loadHandles(); ->withPHIDs($flat_phids)
->execute();
foreach ($handle_phids as $conpherence_phid => $phids) { foreach ($handle_phids as $conpherence_phid => $phids) {
$conpherence = $conpherences[$conpherence_phid]; $conpherence = $conpherences[$conpherence_phid];
$conpherence->attachHandles(array_select_keys($handles, $phids)); $conpherence->attachHandles(array_select_keys($handles, $phids));
@ -239,9 +240,10 @@ final class ConpherenceThreadQuery
->execute(); ->execute();
$files = mpull($files, null, 'getPHID'); $files = mpull($files, null, 'getPHID');
$file_author_phids = mpull($files, 'getAuthorPHID', 'getPHID'); $file_author_phids = mpull($files, 'getAuthorPHID', 'getPHID');
$authors = id(new PhabricatorObjectHandleData($file_author_phids)) $authors = id(new PhabricatorHandleQuery())
->setViewer($this->getViewer()) ->setViewer($this->getViewer())
->loadHandles(); ->withPHIDs($file_author_phids)
->execute();
$authors = mpull($authors, null, 'getPHID'); $authors = mpull($authors, null, 'getPHID');
} }

View file

@ -33,9 +33,10 @@ final class PhabricatorCountdownSearchEngine
AphrontFormView $form, AphrontFormView $form,
PhabricatorSavedQuery $saved_query) { PhabricatorSavedQuery $saved_query) {
$phids = $saved_query->getParameter('authorPHIDs', array()); $phids = $saved_query->getParameter('authorPHIDs', array());
$handles = id(new PhabricatorObjectHandleData($phids)) $handles = id(new PhabricatorHandleQuery())
->setViewer($this->requireViewer()) ->setViewer($this->requireViewer())
->loadHandles(); ->withPHIDs($phids)
->execute();
$author_tokens = mpull($handles, 'getFullName', 'getPHID'); $author_tokens = mpull($handles, 'getFullName', 'getPHID');
$upcoming = $saved_query->getParameter('upcoming'); $upcoming = $saved_query->getParameter('upcoming');

View file

@ -97,9 +97,10 @@ final class ConduitAPI_differential_getcommitmessage_Method
$aux_phids[$field_key] = $field->getRequiredHandlePHIDsForCommitMessage(); $aux_phids[$field_key] = $field->getRequiredHandlePHIDsForCommitMessage();
} }
$phids = array_unique(array_mergev($aux_phids)); $phids = array_unique(array_mergev($aux_phids));
$handles = id(new PhabricatorObjectHandleData($phids)) $handles = id(new PhabricatorHandleQuery())
->setViewer($request->getUser()) ->setViewer($request->getUser())
->loadHandles(); ->withPHIDs($phids)
->execute();
foreach ($aux_fields as $field_key => $field) { foreach ($aux_fields as $field_key => $field) {
$field->setHandles(array_select_keys($handles, $aux_phids[$field_key])); $field->setHandles(array_select_keys($handles, $aux_phids[$field_key]));
} }

View file

@ -65,9 +65,10 @@ final class ConduitAPI_differential_getrevision_Method
$commit_dicts = array(); $commit_dicts = array();
$commit_phids = $revision->loadCommitPHIDs(); $commit_phids = $revision->loadCommitPHIDs();
$handles = id(new PhabricatorObjectHandleData($commit_phids)) $handles = id(new PhabricatorHandleQuery())
->setViewer($request->getUser()) ->setViewer($request->getUser())
->loadHandles(); ->withPHIDs($commit_phids)
->execute();
foreach ($commit_phids as $commit_phid) { foreach ($commit_phids as $commit_phid) {
$commit_dicts[] = array( $commit_dicts[] = array(

View file

@ -573,9 +573,10 @@ final class DifferentialCommentEditor extends PhabricatorEditor {
$revision->saveTransaction(); $revision->saveTransaction();
$phids = array($actor_phid); $phids = array($actor_phid);
$handles = id(new PhabricatorObjectHandleData($phids)) $handles = id(new PhabricatorHandleQuery())
->setViewer($this->getActor()) ->setViewer($this->getActor())
->loadHandles(); ->withPHIDs($phids)
->execute();
$actor_handle = $handles[$actor_phid]; $actor_handle = $handles[$actor_phid];
$xherald_header = HeraldTranscript::loadXHeraldRulesHeader( $xherald_header = HeraldTranscript::loadXHeraldRulesHeader(

View file

@ -344,9 +344,10 @@ final class DifferentialRevisionEditor extends PhabricatorEditor {
$phids = array($this->getActorPHID()); $phids = array($this->getActorPHID());
$handles = id(new PhabricatorObjectHandleData($phids)) $handles = id(new PhabricatorHandleQuery())
->setViewer($this->getActor()) ->setViewer($this->getActor())
->loadHandles(); ->withPHIDs($phids)
->execute();
$actor_handle = $handles[$this->getActorPHID()]; $actor_handle = $handles[$this->getActorPHID()];
$changesets = null; $changesets = null;

View file

@ -44,9 +44,10 @@ final class DifferentialHovercardEventListener extends PhutilEventListener {
$reviewer_phids, $reviewer_phids,
$tasks); $tasks);
$handles = id(new PhabricatorObjectHandleData($phids)) $handles = id(new PhabricatorHandleQuery())
->setViewer($viewer) ->setViewer($viewer)
->loadHandles(); ->withPHIDs($phids)
->execute();
$hovercard->setTitle('D'.$rev->getID()); $hovercard->setTitle('D'.$rev->getID());
$hovercard->setDetail($rev->getTitle()); $hovercard->setDetail($rev->getTitle());

View file

@ -47,9 +47,10 @@ final class DifferentialArcanistProjectFieldSpecification
if ($diff) { if ($diff) {
$phid = $diff->getArcanistProjectPHID(); $phid = $diff->getArcanistProjectPHID();
if ($phid) { if ($phid) {
$handle = PhabricatorObjectHandleData::loadOneHandle( $handle = id(new PhabricatorHandleQuery())
$phid, ->setViewer($this->getUser())
$this->getUser()); ->withPHIDs(array($phid))
->executeOne();
return "ARCANIST PROJECT\n ".$handle->getName(); return "ARCANIST PROJECT\n ".$handle->getName();
} }
} }

View file

@ -47,9 +47,10 @@ final class DifferentialCommitsFieldSpecification
} }
$body = array(); $body = array();
$handles = id(new PhabricatorObjectHandleData($phids)) $handles = id(new PhabricatorHandleQuery())
->setViewer($this->getUser()) ->setViewer($this->getUser())
->loadHandles(); ->withPHIDs($phids)
->execute();
$body[] = pht('COMMIT(S)', count($handles)); $body[] = pht('COMMIT(S)', count($handles));
foreach ($handles as $handle) { foreach ($handles as $handle) {

View file

@ -163,9 +163,10 @@ final class DifferentialManiphestTasksFieldSpecification
return null; return null;
} }
$handles = id(new PhabricatorObjectHandleData($this->maniphestTasks)) $handles = id(new PhabricatorHandleQuery())
->setViewer($this->getUser()) ->setViewer($this->getUser())
->loadHandles(); ->withPHIDs($this->maniphestTasks)
->execute();
$body = array(); $body = array();
$body[] = 'MANIPHEST TASKS'; $body[] = 'MANIPHEST TASKS';
foreach ($handles as $handle) { foreach ($handles as $handle) {

View file

@ -164,9 +164,10 @@ final class DifferentialReviewersFieldSpecification
return null; return null;
} }
$handles = id(new PhabricatorObjectHandleData($this->reviewers)) $handles = id(new PhabricatorHandleQuery())
->setViewer($this->getUser()) ->setViewer($this->getUser())
->loadHandles(); ->withPHIDs($this->reviewers)
->execute();
$handles = array_select_keys( $handles = array_select_keys(
$handles, $handles,
array($this->getRevision()->getPrimaryReviewer())) + $handles; array($this->getRevision()->getPrimaryReviewer())) + $handles;

View file

@ -98,9 +98,10 @@ final class DifferentialCommentMail extends DifferentialMail {
array()); array());
$load = array_merge($m_reviewers, $m_cc); $load = array_merge($m_reviewers, $m_cc);
if ($load) { if ($load) {
$handles = id(new PhabricatorObjectHandleData($load)) $handles = id(new PhabricatorHandleQuery())
->setViewer($this->getActor()) ->setViewer($this->getActor())
->loadHandles(); ->withPHIDs($load)
->execute();
if ($m_reviewers) { if ($m_reviewers) {
$this->addedReviewers = $this->renderHandleList($handles, $m_reviewers); $this->addedReviewers = $this->renderHandleList($handles, $m_reviewers);
} }

View file

@ -132,9 +132,10 @@ abstract class DifferentialMail extends PhabricatorMail {
$raw = $revision->getRawRelations($relation_subscribed); $raw = $revision->getRawRelations($relation_subscribed);
$reason_phids = ipull($raw, 'reasonPHID'); $reason_phids = ipull($raw, 'reasonPHID');
$reason_handles = id(new PhabricatorObjectHandleData($reason_phids)) $reason_handles = id(new PhabricatorHandleQuery())
->setViewer($this->getActor()) ->setViewer($this->getActor())
->loadHandles(); ->withPHIDs($reason_phids)
->execute();
$explicit_cc = array(); $explicit_cc = array();
foreach ($raw as $relation) { foreach ($raw as $relation) {
@ -173,12 +174,14 @@ abstract class DifferentialMail extends PhabricatorMail {
} }
$phids = array_keys($phids); $phids = array_keys($phids);
$handles = id(new PhabricatorObjectHandleData($phids)) $handles = id(new PhabricatorHandleQuery())
->setViewer($this->getActor()) ->setViewer($this->getActor())
->loadHandles(); ->withPHIDs($phids)
$objects = id(new PhabricatorObjectHandleData($phids)) ->execute();
$objects = id(new PhabricatorObjectQuery())
->setViewer($this->getActor()) ->setViewer($this->getActor())
->loadObjects(); ->withPHIDs($phids)
->execute();
$to_handles = array_select_keys($handles, $to_phids); $to_handles = array_select_keys($handles, $to_phids);
$cc_handles = array_select_keys($handles, $cc_phids); $cc_handles = array_select_keys($handles, $cc_phids);

View file

@ -107,9 +107,10 @@ final class DifferentialRevisionSearchEngine
$subscriber_phids, $subscriber_phids,
)); ));
$handles = id(new PhabricatorObjectHandleData($all_phids)) $handles = id(new PhabricatorHandleQuery())
->setViewer($this->requireViewer()) ->setViewer($this->requireViewer())
->loadHandles(); ->withPHIDs($all_phids)
->execute();
$tokens = mpull($handles, 'getFullName', 'getPHID'); $tokens = mpull($handles, 'getFullName', 'getPHID');

View file

@ -104,9 +104,10 @@ final class DifferentialSearchIndexer
} }
$ccphids = $rev->getCCPHIDs(); $ccphids = $rev->getCCPHIDs();
$handles = id(new PhabricatorObjectHandleData($ccphids)) $handles = id(new PhabricatorHandleQuery())
->setViewer(PhabricatorUser::getOmnipotentUser()) ->setViewer(PhabricatorUser::getOmnipotentUser())
->loadHandles(); ->withPHIDs($ccphids)
->execute();
foreach ($handles as $phid => $handle) { foreach ($handles as $phid => $handle) {
$doc->addRelationship( $doc->addRelationship(

View file

@ -56,9 +56,10 @@ final class DiffusionDoorkeeperCommitFeedStoryPublisher
// audit) and "passive" (no action necessary) user are. // audit) and "passive" (no action necessary) user are.
$auditor_phids = mpull($requests, 'getAuditorPHID'); $auditor_phids = mpull($requests, 'getAuditorPHID');
$objects = id(new PhabricatorObjectHandleData($auditor_phids)) $objects = id(new PhabricatorObjectQuery())
->setViewer($this->getViewer()) ->setViewer($this->getViewer())
->loadObjects(); ->withPHIDs($auditor_phids)
->execute();
$active = array(); $active = array();
$passive = array(); $passive = array();

View file

@ -38,9 +38,10 @@ final class DiffusionHovercardEventListener extends PhutilEventListener {
$author, $author,
)); ));
$handles = id(new PhabricatorObjectHandleData($phids)) $handles = id(new PhabricatorHandleQuery())
->setViewer($viewer) ->setViewer($viewer)
->loadHandles(); ->withPHIDs($phids)
->execute();
if ($author) { if ($author) {
$author = $handles[$author]->renderLink(); $author = $handles[$author]->renderLink();

View file

@ -46,9 +46,10 @@ final class PhabricatorFileSearchEngine
PhabricatorSavedQuery $saved_query) { PhabricatorSavedQuery $saved_query) {
$phids = $saved_query->getParameter('authorPHIDs', array()); $phids = $saved_query->getParameter('authorPHIDs', array());
$handles = id(new PhabricatorObjectHandleData($phids)) $handles = id(new PhabricatorHandleQuery())
->setViewer($this->requireViewer()) ->setViewer($this->requireViewer())
->loadHandles(); ->withPHIDs($phids)
->execute();
$author_tokens = mpull($handles, 'getFullName', 'getPHID'); $author_tokens = mpull($handles, 'getFullName', 'getPHID');
$explicit = $saved_query->getParameter('explicit'); $explicit = $saved_query->getParameter('explicit');

View file

@ -11,10 +11,11 @@ abstract class ConduitAPI_flag_Method extends ConduitAPIMethod {
} }
protected function attachHandleToFlag($flag, PhabricatorUser $user) { protected function attachHandleToFlag($flag, PhabricatorUser $user) {
$flag->attachHandle( $handle = id(new PhabricatorHandleQuery())
PhabricatorObjectHandleData::loadOneHandle( ->setViewer($user)
$flag->getObjectPHID(), ->withPHIDs(array($flag->getObjectPHID()))
$user)); ->executeOne();
$flag->attachHandle($handle);
} }
protected function buildFlagInfoDictionary($flag) { protected function buildFlagInfoDictionary($flag) {

View file

@ -13,7 +13,10 @@ final class PhabricatorFlagEditController extends PhabricatorFlagController {
$user = $request->getUser(); $user = $request->getUser();
$phid = $this->phid; $phid = $this->phid;
$handle = PhabricatorObjectHandleData::loadOneHandle($phid, $user); $handle = id(new PhabricatorHandleQuery())
->setViewer($user)
->withPHIDs(array($phid))
->executeOne();
if (!$handle->isComplete()) { if (!$handle->isComplete()) {
return new Aphront404Response(); return new Aphront404Response();

View file

@ -596,9 +596,10 @@ abstract class HeraldAdapter {
pht('Object already flagged.')); pht('Object already flagged.'));
} }
$handle = PhabricatorObjectHandleData::loadOneHandle( $handle = id(new PhabricatorHandleQuery())
$phid, ->setViewer($user)
$user); ->withPHIDs(array($phid))
->executeOne();
$flag = new PhabricatorFlag(); $flag = new PhabricatorFlag();
$flag->setOwnerPHID($user->getPHID()); $flag->setOwnerPHID($user->getPHID());

View file

@ -44,9 +44,10 @@ final class HeraldRuleSearchEngine
PhabricatorSavedQuery $saved_query) { PhabricatorSavedQuery $saved_query) {
$phids = $saved_query->getParameter('authorPHIDs', array()); $phids = $saved_query->getParameter('authorPHIDs', array());
$handles = id(new PhabricatorObjectHandleData($phids)) $handles = id(new PhabricatorHandleQuery())
->setViewer($this->requireViewer()) ->setViewer($this->requireViewer())
->loadHandles(); ->withPHIDs($phids)
->execute();
$author_tokens = mpull($handles, 'getFullName', 'getPHID'); $author_tokens = mpull($handles, 'getFullName', 'getPHID');
$content_type = $saved_query->getParameter('contentType'); $content_type = $saved_query->getParameter('contentType');

View file

@ -49,9 +49,10 @@ final class LegalpadDocumentSearchEngine
$contributor_phids = $saved_query->getParameter( $contributor_phids = $saved_query->getParameter(
'contributorPHIDs', array()); 'contributorPHIDs', array());
$phids = array_merge($creator_phids, $contributor_phids); $phids = array_merge($creator_phids, $contributor_phids);
$handles = id(new PhabricatorObjectHandleData($phids)) $handles = id(new PhabricatorHandleQuery())
->setViewer($this->requireViewer()) ->setViewer($this->requireViewer())
->loadHandles(); ->withPHIDs($phids)
->execute();
$tokens = mpull($handles, 'getFullName', 'getPHID'); $tokens = mpull($handles, 'getFullName', 'getPHID');
$form $form

View file

@ -65,8 +65,10 @@ final class PhabricatorLipsumGenerateWorkflow
try { try {
$taskgen = newv($type, array()); $taskgen = newv($type, array());
$object = $taskgen->generate(); $object = $taskgen->generate();
$handle = PhabricatorObjectHandleData::loadOneHandle($object->getPHID(), $handle = id(new PhabricatorHandleQuery())
$admin); ->setViewer($admin)
->withPHIDs(array($object->getPHID()))
->executeOne();
echo "Generated ".$handle->getTypeName().": ". echo "Generated ".$handle->getTypeName().": ".
$handle->getFullName()."\n"; $handle->getFullName()."\n";
} catch (PhutilMissingSymbolException $ex) { } catch (PhutilMissingSymbolException $ex) {

View file

@ -66,9 +66,10 @@ final class PhabricatorMacroSearchEngine
PhabricatorSavedQuery $saved_query) { PhabricatorSavedQuery $saved_query) {
$phids = $saved_query->getParameter('authorPHIDs', array()); $phids = $saved_query->getParameter('authorPHIDs', array());
$handles = id(new PhabricatorObjectHandleData($phids)) $handles = id(new PhabricatorHandleQuery())
->setViewer($this->requireViewer()) ->setViewer($this->requireViewer())
->loadHandles(); ->withPHIDs($phids)
->execute();
$author_tokens = mpull($handles, 'getFullName', 'getPHID'); $author_tokens = mpull($handles, 'getFullName', 'getPHID');
$status = $saved_query->getParameter('status'); $status = $saved_query->getParameter('status');

View file

@ -511,7 +511,7 @@ final class ManiphestTaskQuery
} }
$projects = id(new PhabricatorProjectQuery()) $projects = id(new PhabricatorProjectQuery())
->setViewer($this->viewer) ->setViewer($this->getViewer())
->withMemberPHIDs($this->anyUserProjectPHIDs) ->withMemberPHIDs($this->anyUserProjectPHIDs)
->execute(); ->execute();
$any_user_project_phids = mpull($projects, 'getPHID'); $any_user_project_phids = mpull($projects, 'getPHID');
@ -661,12 +661,10 @@ final class ManiphestTaskQuery
} }
} }
// TODO: This should use the query's viewer once this class extends $handles = id(new PhabricatorHandleQuery())
// PhabricatorPolicyQuery (T603). ->setViewer($this->getViewer())
->withPHIDs(array_keys($project_phids))
$handles = id(new PhabricatorObjectHandleData(array_keys($project_phids))) ->execute();
->setViewer(PhabricatorUser::getOmnipotentUser())
->loadHandles();
$max = 1; $max = 1;
foreach ($handles as $handle) { foreach ($handles as $handle) {

View file

@ -92,9 +92,10 @@ abstract class ManiphestController extends PhabricatorController {
$phids[] = $task->getOwnerPHID(); $phids[] = $task->getOwnerPHID();
} }
$handles = id(new PhabricatorObjectHandleData($phids)) $handles = id(new PhabricatorHandleQuery())
->setViewer($user) ->setViewer($user)
->loadHandles(); ->withPHIDs($phids)
->execute();
$view = id(new ManiphestTaskListView()) $view = id(new ManiphestTaskListView())
->setUser($user) ->setUser($user)

View file

@ -578,9 +578,10 @@ final class ManiphestTaskListController extends ManiphestController {
$any_project_phids, $any_project_phids,
$any_user_project_phids, $any_user_project_phids,
array_mergev(mpull($data, 'getProjectPHIDs'))); array_mergev(mpull($data, 'getProjectPHIDs')));
$handles = id(new PhabricatorObjectHandleData($handle_phids)) $handles = id(new PhabricatorHandleQuery())
->setViewer($viewer) ->setViewer($viewer)
->loadHandles(); ->withPHIDs($handle_phids)
->execute();
switch ($search_query->getParameter('group')) { switch ($search_query->getParameter('group')) {
case 'priority': case 'priority':

View file

@ -129,10 +129,11 @@ final class ManiphestTransactionEditor extends PhabricatorEditor {
break; break;
case ManiphestTransactionType::TYPE_OWNER: case ManiphestTransactionType::TYPE_OWNER:
if ($new) { if ($new) {
$handles = id(new PhabricatorObjectHandleData(array($new))) $handle = id(new PhabricatorHandleQuery())
->setViewer($this->getActor()) ->setViewer($this->getActor())
->loadHandles(); ->withPHIDs(array($new))
$task->setOwnerOrdering($handles[$new]->getName()); ->executeOne();
$task->setOwnerOrdering($handle->getName());
} else { } else {
$task->setOwnerOrdering(null); $task->setOwnerOrdering(null);
} }
@ -226,9 +227,10 @@ final class ManiphestTransactionEditor extends PhabricatorEditor {
} }
$phids = array_keys($phids); $phids = array_keys($phids);
$handles = id(new PhabricatorObjectHandleData($phids)) $handles = id(new PhabricatorHandleQuery())
->setViewer($this->getActor()) ->setViewer($this->getActor())
->loadHandles(); ->withPHIDs($phids)
->execute();
$view = new ManiphestTransactionDetailView(); $view = new ManiphestTransactionDetailView();
$view->setTransactionGroup($transactions); $view->setTransactionGroup($transactions);

View file

@ -97,9 +97,10 @@ final class ManiphestHovercardEventListener extends PhutilEventListener {
} }
protected function loadHandles(array $phids, $viewer) { protected function loadHandles(array $phids, $viewer) {
return id(new PhabricatorObjectHandleData($phids)) return id(new PhabricatorHandleQuery())
->setViewer($viewer) ->setViewer($viewer)
->loadHandles(); ->withPHIDs($phids)
->execute();
} }
} }

View file

@ -110,9 +110,10 @@ final class ManiphestSearchIndexer
// We need to load handles here since non-users may subscribe (mailing // We need to load handles here since non-users may subscribe (mailing
// lists, e.g.) // lists, e.g.)
$handles = id(new PhabricatorObjectHandleData(array_keys($ccs))) $handles = id(new PhabricatorHandleQuery())
->setViewer(PhabricatorUser::getOmnipotentUser()) ->setViewer(PhabricatorUser::getOmnipotentUser())
->loadHandles(); ->withPHIDs(array_keys($ccs))
->execute();
foreach ($ccs as $cc => $time) { foreach ($ccs as $cc => $time) {
$doc->addRelationship( $doc->addRelationship(
PhabricatorSearchRelationship::RELATIONSHIP_SUBSCRIBER, PhabricatorSearchRelationship::RELATIONSHIP_SUBSCRIBER,

View file

@ -36,9 +36,10 @@ final class PhabricatorMailManagementListInboundWorkflow
$phids = array_merge( $phids = array_merge(
mpull($mails, 'getRelatedPHID'), mpull($mails, 'getRelatedPHID'),
mpull($mails, 'getAuthorPHID')); mpull($mails, 'getAuthorPHID'));
$handles = id(new PhabricatorObjectHandleData($phids)) $handles = id(new PhabricatorHandleQuery())
->setViewer($viewer) ->setViewer($viewer)
->loadHandles(); ->withPHIDs($phids)
->execute();
foreach (array_reverse($mails) as $mail) { foreach (array_reverse($mails) as $mail) {
$console->writeOut( $console->writeOut(

View file

@ -87,12 +87,11 @@ abstract class PhabricatorMailReplyHandler {
$template->setBody($this->buildErrorMailBody($error, $mail)); $template->setBody($this->buildErrorMailBody($error, $mail));
$template->setRelatedPHID($mail->getRelatedPHID()); $template->setRelatedPHID($mail->getRelatedPHID());
$phid = $this->getActor()->getPHID(); $phid = $this->getActor()->getPHID();
$tos = array( $handle = id(new PhabricatorHandleQuery())
$phid => PhabricatorObjectHandleData::loadOneHandle( ->setViewer($this->getActor())
$phid, ->withPHIDs(array($phid))
// TODO: This could be cleaner (T603). ->executeOne();
PhabricatorUser::getOmnipotentUser()), $tos = array($phid => $handle);
);
$mails = $this->multiplexMail($template, $tos, array()); $mails = $this->multiplexMail($template, $tos, array());
foreach ($mails as $email) { foreach ($mails as $email) {

View file

@ -80,9 +80,10 @@ abstract class PackageMail extends PhabricatorMail {
$this->mailTo, $this->mailTo,
array($package->getActorPHID()), array($package->getActorPHID()),
array_keys($this->paths)); array_keys($this->paths));
$this->handles = id(new PhabricatorObjectHandleData($phids)) $this->handles = id(new PhabricatorHandleQuery())
->setViewer($this->getActor()) ->setViewer($this->getActor())
->loadHandles(); ->withPHIDs($phids)
->execute();
} }
final protected function renderSummarySection() { final protected function renderSummarySection() {

View file

@ -59,9 +59,10 @@ final class PackageModifyMail extends PackageMail {
array( array(
$this->getPackage()->getActorPHID(), $this->getPackage()->getActorPHID(),
)); ));
$this->handles = id(new PhabricatorObjectHandleData($phids)) $this->handles = id(new PhabricatorHandleQuery())
->setViewer($this->getActor()) ->setViewer($this->getActor())
->loadHandles(); ->withPHIDs($phids)
->execute();
} }
protected function renderDescriptionSection() { protected function renderDescriptionSection() {

View file

@ -48,9 +48,10 @@ final class PhabricatorPasteSearchEngine
AphrontFormView $form, AphrontFormView $form,
PhabricatorSavedQuery $saved_query) { PhabricatorSavedQuery $saved_query) {
$phids = $saved_query->getParameter('authorPHIDs', array()); $phids = $saved_query->getParameter('authorPHIDs', array());
$handles = id(new PhabricatorObjectHandleData($phids)) $handles = id(new PhabricatorHandleQuery())
->setViewer($this->requireViewer()) ->setViewer($this->requireViewer())
->loadHandles(); ->withPHIDs($phids)
->execute();
$author_tokens = mpull($handles, 'getFullName', 'getPHID'); $author_tokens = mpull($handles, 'getFullName', 'getPHID');
$languages = $saved_query->getParameter('languages', array()); $languages = $saved_query->getParameter('languages', array());

View file

@ -62,10 +62,11 @@ final class PhameBlogFeedController extends PhameController {
} }
$engine->process(); $engine->process();
$bloggers = mpull($posts, 'getBloggerPHID'); $blogger_phids = mpull($posts, 'getBloggerPHID');
$bloggers = id(new PhabricatorObjectHandleData($bloggers)) $bloggers = id(new PhabricatorHandleQuery())
->setViewer($user) ->setViewer($user)
->loadHandles(); ->withPHIDs($blogger_phids)
->execute();
foreach ($posts as $post) { foreach ($posts as $post) {
$content[] = hsprintf('<entry>'); $content[] = hsprintf('<entry>');

View file

@ -94,9 +94,10 @@ final class PhamePostEditController
} }
} }
$handle = PhabricatorObjectHandleData::loadOneHandle( $handle = id(new PhabricatorHandleQuery())
$post->getBlogPHID(), ->withViewer($user)
$user); ->withPHIDs(array($post->getBlogPHID()))
->executeOne();
$form = id(new AphrontFormView()) $form = id(new AphrontFormView())
->setUser($user) ->setUser($user)

View file

@ -294,9 +294,10 @@ abstract class PhameBasicBlogSkin extends PhameBlogSkin {
$phids[] = $post->getBloggerPHID(); $phids[] = $post->getBloggerPHID();
} }
$handles = id(new PhabricatorObjectHandleData($phids)) $handles = id(new PhabricatorHandleQuery())
->setViewer($user) ->setViewer($user)
->loadHandles(); ->withPHIDs($phids)
->execute();
$engine->process(); $engine->process();

View file

@ -93,47 +93,10 @@ final class PhameBlog extends PhameDAO
return $valid; return $valid;
} }
public function loadBloggerPHIDs() {
if (!$this->getPHID()) {
return $this;
}
if ($this->bloggerPHIDs) {
return $this;
}
$this->bloggerPHIDs = PhabricatorEdgeQuery::loadDestinationPHIDs(
$this->getPHID(),
PhabricatorEdgeConfig::TYPE_BLOG_HAS_BLOGGER);
return $this;
}
public function getBloggerPHIDs() { public function getBloggerPHIDs() {
return $this->assertAttached($this->bloggerPHIDs); return $this->assertAttached($this->bloggerPHIDs);
} }
public function loadBloggers() {
if ($this->bloggers) {
return $this->bloggers;
}
$blogger_phids = $this->loadBloggerPHIDs()->getBloggerPHIDs();
if (empty($blogger_phids)) {
return array();
}
$bloggers = id(new PhabricatorObjectHandleData($blogger_phids))
// TODO: This should be Query-based (T603).
->setViewer(PhabricatorUser::getOmnipotentUser())
->loadHandles();
$this->attachBloggers($bloggers);
return $this;
}
public function attachBloggers(array $bloggers) { public function attachBloggers(array $bloggers) {
assert_instances_of($bloggers, 'PhabricatorObjectHandle'); assert_instances_of($bloggers, 'PhabricatorObjectHandle');

View file

@ -130,7 +130,7 @@ final class PhabricatorObjectHandle
* completely loaded (e.g., the type or data for the PHID could not be * completely loaded (e.g., the type or data for the PHID could not be
* identified or located). * identified or located).
* *
* Basically, @{class:PhabricatorObjectHandleData} gives you back a handle for * Basically, @{class:PhabricatorHandleQuery} gives you back a handle for
* any PHID you give it, but it gives you a complete handle only for valid * any PHID you give it, but it gives you a complete handle only for valid
* PHIDs. * PHIDs.
* *

View file

@ -38,11 +38,11 @@ final class ConduitAPI_phid_info_Method
$phid = $request->getValue('phid'); $phid = $request->getValue('phid');
$handles = id(new PhabricatorObjectHandleData(array($phid))) $handle = id(new PhabricatorHandleQuery())
->setViewer($request->getUser()) ->setViewer($request->getUser())
->loadHandles(); ->withPHIDs(array($phid))
->executeOne();
$handle = $handles[$phid];
if (!$handle->isComplete()) { if (!$handle->isComplete()) {
throw new ConduitException('ERR-BAD-PHID'); throw new ConduitException('ERR-BAD-PHID');
} }

View file

@ -33,9 +33,10 @@ final class ConduitAPI_phid_lookup_Method
$query->execute(); $query->execute();
$name_map = $query->getNamedResults(); $name_map = $query->getNamedResults();
$handles = id(new PhabricatorObjectHandleData(mpull($name_map, 'getPHID'))) $handles = id(new PhabricatorHandleQuery())
->setViewer($request->getUser()) ->setViewer($request->getUser())
->loadHandles(); ->withPHIDs(mpull($name_map, 'getPHID'))
->execute();
$result = array(); $result = array();
foreach ($name_map as $name => $object) { foreach ($name_map as $name => $object) {

View file

@ -28,9 +28,10 @@ final class ConduitAPI_phid_query_Method
$phids = $request->getValue('phids'); $phids = $request->getValue('phids');
$handles = id(new PhabricatorObjectHandleData($phids)) $handles = id(new PhabricatorHandleQuery())
->setViewer($request->getUser()) ->setViewer($request->getUser())
->loadHandles(); ->withPHIDs($phids)
->execute();
$result = array(); $result = array();
foreach ($handles as $phid => $handle) { foreach ($handles as $phid => $handle) {

View file

@ -1,83 +0,0 @@
<?php
final class PhabricatorObjectHandleData {
private $phids;
private $viewer;
public function __construct(array $phids) {
$this->phids = array_unique($phids);
}
public function setViewer(PhabricatorUser $viewer) {
$this->viewer = $viewer;
return $this;
}
public static function loadOneHandle($phid, PhabricatorUser $viewer) {
$query = new PhabricatorObjectHandleData(array($phid));
$query->setViewer($viewer);
$handles = $query->loadHandles();
return $handles[$phid];
}
public function loadObjects() {
$phids = array_fuse($this->phids);
return id(new PhabricatorObjectQuery())
->setViewer($this->viewer)
->withPHIDs($phids)
->execute();
}
public function loadHandles() {
$application_handles = id(new PhabricatorHandleQuery())
->setViewer($this->viewer)
->withPHIDs($this->phids)
->execute();
// TODO: Move the rest of this into Applications.
$phid_map = array_fuse($this->phids);
foreach ($application_handles as $handle) {
if ($handle->isComplete()) {
unset($phid_map[$handle->getPHID()]);
}
}
$types = phid_group_by_type($phid_map);
$handles = array();
foreach ($types as $type => $phids) {
switch ($type) {
case PhabricatorPHIDConstants::PHID_TYPE_MAGIC:
// Black magic!
foreach ($phids as $phid) {
$handle = new PhabricatorObjectHandle();
$handle->setPHID($phid);
$handle->setType($type);
switch ($phid) {
case ManiphestTaskOwner::OWNER_UP_FOR_GRABS:
$handle->setName('Up For Grabs');
$handle->setFullName('upforgrabs (Up For Grabs)');
$handle->setComplete(true);
break;
case ManiphestTaskOwner::PROJECT_NO_PROJECT:
$handle->setName('No Project');
$handle->setFullName('noproject (No Project)');
$handle->setComplete(true);
break;
default:
$handle->setName('Foul Magicks');
break;
}
$handles[$phid] = $handle;
}
break;
}
}
return $handles + $application_handles;
}
}

View file

@ -225,9 +225,10 @@ final class PholioMockEditController extends PholioController {
// NOTE: Make this show up correctly on the rendered form. // NOTE: Make this show up correctly on the rendered form.
$mock->setViewPolicy($v_view); $mock->setViewPolicy($v_view);
$handles = id(new PhabricatorObjectHandleData($v_cc)) $handles = id(new PhabricatorHandleQuery())
->setViewer($user) ->setViewer($user)
->loadHandles(); ->withPHIDs($v_cc)
->execute();
$cc_tokens = mpull($handles, 'getFullName', 'getPHID'); $cc_tokens = mpull($handles, 'getFullName', 'getPHID');

View file

@ -27,9 +27,10 @@ final class PholioMockSearchEngine
PhabricatorSavedQuery $saved_query) { PhabricatorSavedQuery $saved_query) {
$phids = $saved_query->getParameter('authorPHIDs', array()); $phids = $saved_query->getParameter('authorPHIDs', array());
$handles = id(new PhabricatorObjectHandleData($phids)) $handles = id(new PhabricatorHandleQuery())
->setViewer($this->requireViewer()) ->setViewer($this->requireViewer())
->loadHandles(); ->withPHIDs($phids)
->execute();
$author_tokens = mpull($handles, 'getFullName', 'getPHID'); $author_tokens = mpull($handles, 'getFullName', 'getPHID');
$form $form

View file

@ -146,9 +146,10 @@ final class PhrequentListController extends PhrequentController {
->setUser($user) ->setUser($user)
->setAction($this->getApplicationURI("/view/custom/")); ->setAction($this->getApplicationURI("/view/custom/"));
$user_handles = id(new PhabricatorObjectHandleData($user_phids)) $user_handles = id(new PhabricatorHandleQuery())
->setViewer($user) ->setViewer($user)
->loadHandles(); ->withPHIDs($user_phids)
->execute();
$tokens = array(); $tokens = array();
foreach ($user_phids as $phid) { foreach ($user_phids as $phid) {
$tokens[$phid] = $user_handles[$phid]->getFullName(); $tokens[$phid] = $user_handles[$phid]->getFullName();

View file

@ -272,9 +272,10 @@ final class PhabricatorPolicyFilter {
$who = "No one can {$verb} this object."; $who = "No one can {$verb} this object.";
break; break;
default: default:
$handle = PhabricatorObjectHandleData::loadOneHandle( $handle = id(new PhabricatorHandleQuery())
$policy, ->setViewer($this->viewer)
$this->viewer); ->withPHIDs(array($policy))
->executeOne();
$type = phid_get_type($policy); $type = phid_get_type($policy);
if ($type == PhabricatorProjectPHIDTypeProject::TYPECONST) { if ($type == PhabricatorProjectPHIDTypeProject::TYPECONST) {

View file

@ -100,9 +100,10 @@ final class PhabricatorPolicyQuery extends PhabricatorQuery {
$other_policies = array_diff_key($other_policies, $results); $other_policies = array_diff_key($other_policies, $results);
if ($other_policies) { if ($other_policies) {
$handles = id(new PhabricatorObjectHandleData($other_policies)) $handles = id(new PhabricatorHandleQuery())
->setViewer($this->viewer) ->setViewer($this->viewer)
->loadHandles(); ->withPHIDs($other_policies)
->execute();
foreach ($other_policies as $phid) { foreach ($other_policies as $phid) {
$results[$phid] = PhabricatorPolicy::newFromPolicyAndHandle( $results[$phid] = PhabricatorPolicy::newFromPolicyAndHandle(
$phid, $phid,

View file

@ -57,9 +57,10 @@ final class PonderQuestionSearchEngine
'status', PonderQuestionStatus::STATUS_OPEN); 'status', PonderQuestionStatus::STATUS_OPEN);
$phids = array_merge($author_phids, $answerer_phids); $phids = array_merge($author_phids, $answerer_phids);
$handles = id(new PhabricatorObjectHandleData($phids)) $handles = id(new PhabricatorHandleQuery())
->setViewer($this->requireViewer()) ->setViewer($this->requireViewer())
->loadHandles(); ->withPHIDs($phids)
->execute();
$tokens = mpull($handles, 'getFullName', 'getPHID'); $tokens = mpull($handles, 'getFullName', 'getPHID');
$author_tokens = array_select_keys($tokens, $author_phids); $author_tokens = array_select_keys($tokens, $author_phids);

View file

@ -36,9 +36,10 @@ final class PhabricatorProjectSearchEngine
PhabricatorSavedQuery $saved_query) { PhabricatorSavedQuery $saved_query) {
$phids = $saved_query->getParameter('memberPHIDs', array()); $phids = $saved_query->getParameter('memberPHIDs', array());
$handles = id(new PhabricatorObjectHandleData($phids)) $handles = id(new PhabricatorHandleQuery())
->setViewer($this->requireViewer()) ->setViewer($this->requireViewer())
->loadHandles(); ->withPHIDs($phids)
->execute();
$member_tokens = mpull($handles, 'getFullName', 'getPHID'); $member_tokens = mpull($handles, 'getFullName', 'getPHID');
$status = $saved_query->getParameter('status'); $status = $saved_query->getParameter('status');

View file

@ -53,11 +53,12 @@ final class ConduitAPI_releeph_request_Method
->setErrorDescription($ex->getMessage()); ->setErrorDescription($ex->getMessage());
} }
} }
$requested_commit_phids = mpull($requested_commits, 'getPHID');
// Find any existing requests that clash on the commit id, for this branch // Find any existing requests that clash on the commit id, for this branch
$existing_releeph_requests = id(new ReleephRequest())->loadAllWhere( $existing_releeph_requests = id(new ReleephRequest())->loadAllWhere(
'requestCommitPHID IN (%Ls) AND branchID = %d', 'requestCommitPHID IN (%Ls) AND branchID = %d',
mpull($requested_commits, 'getPHID'), $requested_commit_phids,
$releeph_branch->getID()); $releeph_branch->getID());
$existing_releeph_requests = mpull( $existing_releeph_requests = mpull(
$existing_releeph_requests, $existing_releeph_requests,
@ -73,11 +74,12 @@ final class ConduitAPI_releeph_request_Method
} }
$results = array(); $results = array();
$handles = id(new PhabricatorHandleQuery())
->setViewer($user)
->withPHIDs($requested_commit_phids)
->execute();
foreach ($requested_commits as $thing => $commit) { foreach ($requested_commits as $thing => $commit) {
$phid = $commit->getPHID(); $phid = $commit->getPHID();
$handles = id(new PhabricatorObjectHandleData(array($phid)))
->setViewer($user)
->loadHandles();
$name = id($handles[$phid])->getName(); $name = id($handles[$phid])->getName();
$releeph_request = null; $releeph_request = null;

View file

@ -34,9 +34,10 @@ final class ConduitAPI_releephwork_getbranch_Method
$cut_phid = $branch->getCutPointCommitPHID(); $cut_phid = $branch->getCutPointCommitPHID();
$phids = array($cut_phid); $phids = array($cut_phid);
$handles = id(new PhabricatorObjectHandleData($phids)) $handles = id(new PhabricatorHandleQuery())
->setViewer($request->getUser()) ->setViewer($request->getUser())
->loadHandles(); ->withPHIDs($phids)
->execute();
$project = $branch->getProject(); $project = $branch->getProject();
$repo = $project->getRepository(); $repo = $project->getRepository();

View file

@ -41,9 +41,10 @@ final class ConduitAPI_releephwork_getbranchcommitmessage_Method
$cut_phid, $cut_phid,
); );
$handles = id(new PhabricatorObjectHandleData($phids)) $handles = id(new PhabricatorHandleQuery())
->setViewer($request->getUser()) ->setViewer($request->getUser())
->loadHandles(); ->withPHIDs($phids)
->execute();
$h_branch = $handles[$branch->getPHID()]; $h_branch = $handles[$branch->getPHID()];
$h_project = $handles[$project->getPHID()]; $h_project = $handles[$project->getPHID()];

View file

@ -117,9 +117,10 @@ final class ConduitAPI_releephwork_nextrequest_Method
} }
$phids[] = $releeph_request->getPHID(); $phids[] = $releeph_request->getPHID();
$handles = id(new PhabricatorObjectHandleData($phids)) $handles = id(new PhabricatorHandleQuery())
->setViewer($request->getUser()) ->setViewer($request->getUser())
->loadHandles(); ->withPHIDs($phids)
->execute();
$diff_name = null; $diff_name = null;
if ($diff_rev) { if ($diff_rev) {

View file

@ -42,9 +42,10 @@ final class ReleephBranchEditController extends ReleephProjectController {
$phids[] = $creator_phid = $releeph_branch->getCreatedByUserPHID(); $phids[] = $creator_phid = $releeph_branch->getCreatedByUserPHID();
$phids[] = $cut_commit_phid = $releeph_branch->getCutPointCommitPHID(); $phids[] = $cut_commit_phid = $releeph_branch->getCutPointCommitPHID();
$handles = id(new PhabricatorObjectHandleData($phids)) $handles = id(new PhabricatorHandleQuery())
->setViewer($request->getUser()) ->setViewer($request->getUser())
->loadHandles(); ->withPHIDs($phids)
->execute();
$form = id(new AphrontFormView()) $form = id(new AphrontFormView())
->setUser($request->getUser()) ->setUser($request->getUser())

View file

@ -130,9 +130,10 @@ final class ReleephProjectEditController extends ReleephProjectController {
'pushers', 'pushers',
$this->getReleephProject()->getDetail('pushers', array())); $this->getReleephProject()->getDetail('pushers', array()));
$handles = id(new PhabricatorObjectHandleData($pusher_phids)) $handles = id(new PhabricatorHandleQuery())
->setViewer($request->getUser()) ->setViewer($request->getUser())
->loadHandles(); ->withPHIDs($pusher_phids)
->execute();
$pusher_tokens = array(); $pusher_tokens = array();
foreach ($pusher_phids as $phid) { foreach ($pusher_phids as $phid) {

View file

@ -24,12 +24,10 @@ final class ReleephBranchEditor extends PhabricatorEditor {
$template = ReleephBranchTemplate::getRequiredDefaultTemplate(); $template = ReleephBranchTemplate::getRequiredDefaultTemplate();
} }
$cut_point_handle = head( $cut_point_handle = id(new PhabricatorHandleQuery())
id(new PhabricatorObjectHandleData(array($cut_point->getPHID())))
// We'll assume that whoever found the $cut_point has passed privacy
// checks.
->setViewer($this->requireActor()) ->setViewer($this->requireActor())
->loadHandles()); ->withPHIDs(array($cut_point->getPHID()))
->executeOne();
list($name, $errors) = id(new ReleephBranchTemplate()) list($name, $errors) = id(new ReleephBranchTemplate())
->setCommitHandle($cut_point_handle) ->setCommitHandle($cut_point_handle)

View file

@ -49,9 +49,10 @@ final class ReleephIntentFieldSpecification
$pusher_phids = $this->getReleephProject()->getPushers(); $pusher_phids = $this->getReleephProject()->getPushers();
$phids = array_unique($pusher_phids + array_keys($intents)); $phids = array_unique($pusher_phids + array_keys($intents));
$handles = id(new PhabricatorObjectHandleData($phids)) $handles = id(new PhabricatorHandleQuery())
->setViewer($this->getUser()) ->setViewer($this->getUser())
->loadHandles(); ->withPHIDs($phids)
->execute();
$tokens = array(); $tokens = array();
foreach ($phids as $phid) { foreach ($phids as $phid) {

View file

@ -40,10 +40,11 @@ final class ReleephRequestorFieldSpecification
public function renderValueForCommitMessage() { public function renderValueForCommitMessage() {
$phid = $this->getReleephRequest()->getRequestUserPHID(); $phid = $this->getReleephRequest()->getRequestUserPHID();
$handles = id(new PhabricatorObjectHandleData(array($phid))) $handle = id(new PhabricatorHandleQuery())
->setViewer($this->getUser()) ->setViewer($this->getUser())
->loadHandles(); ->withPHIDs(array($phid))
return $handles[$phid]->getName(); ->executeOne();
return $handle->getName();
} }
} }

View file

@ -60,9 +60,10 @@ final class ReleephRequestSearchEngine
PhabricatorSavedQuery $saved_query) { PhabricatorSavedQuery $saved_query) {
$phids = $saved_query->getParameter('requestorPHIDs', array()); $phids = $saved_query->getParameter('requestorPHIDs', array());
$handles = id(new PhabricatorObjectHandleData($phids)) $handles = id(new PhabricatorHandleQuery())
->setViewer($this->requireViewer()) ->setViewer($this->requireViewer())
->loadHandles(); ->withPHIDs($phids)
->execute();
$requestor_tokens = mpull($handles, 'getFullName', 'getPHID'); $requestor_tokens = mpull($handles, 'getFullName', 'getPHID');
$form $form

View file

@ -130,9 +130,10 @@ final class ReleephBranch extends ReleephDAO
$phids_to_phetch[] = $rr->loadRequestCommitDiffPHID(); $phids_to_phetch[] = $rr->loadRequestCommitDiffPHID();
} }
} }
$handles = id(new PhabricatorObjectHandleData($phids_to_phetch)) $handles = id(new PhabricatorHandleQuery())
->setViewer($user) ->setViewer($user)
->loadHandles(); ->withPHIDs($phids_to_phetch)
->execute();
return $handles; return $handles;
} }

View file

@ -39,9 +39,10 @@ abstract class ReleephUserView extends AphrontView {
if ($todo) { if ($todo) {
self::$handles = array_merge( self::$handles = array_merge(
self::$handles, self::$handles,
id(new PhabricatorObjectHandleData($todo)) id(new PhabricatorHandleQuery())
->setViewer($this->getUser()) ->setViewer($this->getUser())
->loadHandles()); ->withPHIDs($todo)
->execute());
$this->loadInner($todo); $this->loadInner($todo);
} }
} }

View file

@ -83,9 +83,10 @@ final class PhabricatorRepositoryCommitHeraldWorker
$commit->getPHID(), $commit->getPHID(),
)); ));
$handles = id(new PhabricatorObjectHandleData($phids)) $handles = id(new PhabricatorHandleQuery())
->setViewer(PhabricatorUser::getOmnipotentUser()) ->setViewer(PhabricatorUser::getOmnipotentUser())
->loadHandles(); ->withPHIDs($phids)
->execute();
$commit_handle = $handles[$commit->getPHID()]; $commit_handle = $handles[$commit->getPHID()];
$commit_name = $commit_handle->getName(); $commit_name = $commit_handle->getName();
@ -163,9 +164,10 @@ final class PhabricatorRepositoryCommitHeraldWorker
$mails = $reply_handler->multiplexMail( $mails = $reply_handler->multiplexMail(
$template, $template,
id(new PhabricatorObjectHandleData($email_phids)) id(new PhabricatorHandleQuery())
->setViewer(PhabricatorUser::getOmnipotentUser()) ->setViewer(PhabricatorUser::getOmnipotentUser())
->loadHandles(), ->withPHIDs($email_phids)
->execute(),
array()); array());
foreach ($mails as $mail) { foreach ($mails as $mail) {

View file

@ -226,9 +226,11 @@ abstract class PhabricatorRepositoryCommitMessageParserWorker
if (!$user_phid) { if (!$user_phid) {
return $default; return $default;
} }
$handle = PhabricatorObjectHandleData::loadOneHandle( $handle = id(new PhabricatorHandleQuery())
$user_phid, ->setViewer($actor)
$actor); ->withPHIDs(array($user_phid))
->executeOne();
return '@'.$handle->getName(); return '@'.$handle->getName();
} }

View file

@ -26,16 +26,18 @@ final class PhabricatorSearchAttachController
$request = $this->getRequest(); $request = $this->getRequest();
$user = $request->getUser(); $user = $request->getUser();
$handle_data = new PhabricatorObjectHandleData(array($this->phid)); $handle = id(New PhabricatorHandleQuery())
$handle_data->setViewer($user); ->setViewer($user)
$handles = $handle_data->loadHandles(); ->withPHIDs(array($this->phid))
$handle = $handles[$this->phid]; ->executeOne();
$object_type = $handle->getType(); $object_type = $handle->getType();
$attach_type = $this->type; $attach_type = $this->type;
$objects = $handle_data->loadObjects(); $object = id(new PhabricatorObjectQuery())
$object = idx($objects, $this->phid); ->setViewer($user)
->withPHIDs(array($this->phid))
->executeOne();
if (!$object) { if (!$object) {
return new Aphront404Response(); return new Aphront404Response();

View file

@ -233,11 +233,14 @@ final class PhabricatorSearchController
} }
if ($results) { if ($results) {
$handles = id(new PhabricatorHandleQuery())
$loader = id(new PhabricatorObjectHandleData($results)) ->setViewer($user)
->setViewer($user); ->withPHIDs($results)
$handles = $loader->loadHandles(); ->execute();
$objects = $loader->loadObjects(); $objects = id(new PhabricatorObjectQuery())
->setViewer($user)
->withPHIDs($results)
->execute();
$results = array(); $results = array();
foreach ($handles as $phid => $handle) { foreach ($handles as $phid => $handle) {
$view = id(new PhabricatorSearchResultView()) $view = id(new PhabricatorSearchResultView())

View file

@ -12,10 +12,14 @@ final class PhabricatorSearchHovercardController
$phids = $request->getArr('phids'); $phids = $request->getArr('phids');
$handle_data = new PhabricatorObjectHandleData($phids); $handles = id(new PhabricatorHandleQuery())
$handle_data->setViewer($user); ->setViewer($user)
$handles = $handle_data->loadHandles(); ->withPHIDs($phids)
$objects = $handle_data->loadObjects(); ->execute();
$objects = id(new PhabricatorObjectQuery())
->setViewer($user)
->withPHIDs($phids)
->execute();
$cards = array(); $cards = array();

View file

@ -25,9 +25,10 @@ final class PhabricatorSearchEngineElastic extends PhabricatorSearchEngine {
$type = $doc->getDocumentType(); $type = $doc->getDocumentType();
$phid = $doc->getPHID(); $phid = $doc->getPHID();
$handle = PhabricatorObjectHandleData::loadOneHandle( $handle = id(new PhabricatorHandleQuery())
$phid, ->setViewer(PhabricatorUser::getOmnipotentUser())
PhabricatorUser::getOmnipotentUser()); ->withPHIDs(array($phid))
->executeOne();
// URL is not used internally but it can be useful externally. // URL is not used internally but it can be useful externally.
$spec = array( $spec = array(

View file

@ -29,9 +29,10 @@ final class PhabricatorSlowvoteSearchEngine
AphrontFormView $form, AphrontFormView $form,
PhabricatorSavedQuery $saved_query) { PhabricatorSavedQuery $saved_query) {
$phids = $saved_query->getParameter('authorPHIDs', array()); $phids = $saved_query->getParameter('authorPHIDs', array());
$handles = id(new PhabricatorObjectHandleData($phids)) $handles = id(new PhabricatorHandleQuery())
->setViewer($this->requireViewer()) ->setViewer($this->requireViewer())
->loadHandles(); ->withPHIDs($phids)
->execute();
$author_tokens = mpull($handles, 'getFullName', 'getPHID'); $author_tokens = mpull($handles, 'getFullName', 'getPHID');
$voted = $saved_query->getParameter('voted', false); $voted = $saved_query->getParameter('voted', false);

View file

@ -36,9 +36,10 @@ final class SlowvoteEmbedView extends AphrontView {
} }
$phids[] = $poll->getAuthorPHID(); $phids[] = $poll->getAuthorPHID();
$this->handles = id(new PhabricatorObjectHandleData($phids)) $this->handles = id(new PhabricatorHandleQuery())
->setViewer($this->getUser()) ->setViewer($this->getUser())
->loadHandles(); ->withPHIDs($phids)
->execute();
$options = $poll->getOptions(); $options = $poll->getOptions();

View file

@ -32,17 +32,15 @@ final class PhabricatorSubscriptionsEditController
$user = $request->getUser(); $user = $request->getUser();
$phid = $this->phid; $phid = $this->phid;
// TODO: This is a policy test because `loadObjects()` is not currently $handle = id(new PhabricatorHandleQuery())
// policy-aware. Once it is, we can collapse this.
$handle = PhabricatorObjectHandleData::loadOneHandle($phid, $user);
if (!$handle->isComplete()) {
return new Aphront404Response();
}
$objects = id(new PhabricatorObjectHandleData(array($phid)))
->setViewer($user) ->setViewer($user)
->loadObjects(); ->withPHIDs(array($phid))
$object = idx($objects, $phid); ->executeOne();
$object = id(new PhabricatorObjectQuery())
->setViewer($user)
->withPHIDs(array($phid))
->executeOne();
if (!($object instanceof PhabricatorSubscribableInterface)) { if (!($object instanceof PhabricatorSubscribableInterface)) {
return $this->buildErrorResponse( return $this->buildErrorResponse(

View file

@ -98,9 +98,10 @@ final class PhabricatorSubscriptionsUIEventListener
$subscribers = PhabricatorSubscribersQuery::loadSubscribersForPHID( $subscribers = PhabricatorSubscribersQuery::loadSubscribersForPHID(
$object->getPHID()); $object->getPHID());
if ($subscribers) { if ($subscribers) {
$handles = id(new PhabricatorObjectHandleData($subscribers)) $handles = id(new PhabricatorHandleQuery())
->setViewer($user) ->setViewer($user)
->loadHandles(); ->withPHIDs($subscribers)
->execute();
$sub_view = array(); $sub_view = array();
foreach ($subscribers as $subscriber) { foreach ($subscribers as $subscriber) {
$sub_view[] = $handles[$subscriber]->renderLink(); $sub_view[] = $handles[$subscriber]->renderLink();

View file

@ -12,7 +12,10 @@ final class PhabricatorTokenGiveController extends PhabricatorTokenController {
$request = $this->getRequest(); $request = $this->getRequest();
$user = $request->getUser(); $user = $request->getUser();
$handle = PhabricatorObjectHandleData::loadOneHandle($this->phid, $user); $handle = id(new PhabricatorHandleQuery())
->setViewer($user)
->withPHIDs(array($this->phid))
->executeOne();
if (!$handle->isComplete()) { if (!$handle->isComplete()) {
return new Aphront404Response(); return new Aphront404Response();
} }

View file

@ -18,9 +18,10 @@ final class PhabricatorTokenGivenController extends PhabricatorTokenController {
$object_phids = mpull($tokens_given, 'getObjectPHID'); $object_phids = mpull($tokens_given, 'getObjectPHID');
$user_phids = mpull($tokens_given, 'getAuthorPHID'); $user_phids = mpull($tokens_given, 'getAuthorPHID');
$handle_phids = array_merge($object_phids, $user_phids); $handle_phids = array_merge($object_phids, $user_phids);
$handles = id(new PhabricatorObjectHandleData($handle_phids)) $handles = id(new PhabricatorHandleQuery())
->setViewer($user) ->setViewer($user)
->loadHandles(); ->withPHIDs($handle_phids)
->execute();
} }
$tokens = array(); $tokens = array();

View file

@ -19,9 +19,10 @@ final class PhabricatorTokenLeaderController
$phids = array(); $phids = array();
if ($counts) { if ($counts) {
$phids = mpull($objects, 'getPHID'); $phids = mpull($objects, 'getPHID');
$handles = id(new PhabricatorObjectHandleData($phids)) $handles = id(new PhabricatorHandleQuery())
->setViewer($user) ->setViewer($user)
->loadHandles(); ->withPHIDs($phids)
->execute();
} }
$list = new PHUIObjectItemListView(); $list = new PHUIObjectItemListView();

View file

@ -99,10 +99,10 @@ final class PhabricatorTokenGivenEditor
} }
private function validateObject($object_phid) { private function validateObject($object_phid) {
$objects = id(new PhabricatorObjectHandleData(array($object_phid))) $object = id(new PhabricatorObjectQuery())
->setViewer($this->requireActor()) ->setViewer($this->requireActor())
->loadObjects(); ->withPHIDs(array($object_phid))
$object = head($objects); ->executeOne();
if (!$object) { if (!$object) {
throw new Exception("No such object!"); throw new Exception("No such object!");

View file

@ -93,9 +93,10 @@ final class PhabricatorTokenUIEventListener
$tokens = mpull($tokens, null, 'getPHID'); $tokens = mpull($tokens, null, 'getPHID');
$author_phids = mpull($tokens_given, 'getAuthorPHID'); $author_phids = mpull($tokens_given, 'getAuthorPHID');
$handles = id(new PhabricatorObjectHandleData($author_phids)) $handles = id(new PhabricatorHandleQuery())
->setViewer($user) ->setViewer($user)
->loadHandles(); ->withPHIDs($author_phids)
->execute();
Javelin::initBehavior('phabricator-tooltips'); Javelin::initBehavior('phabricator-tooltips');

View file

@ -72,9 +72,10 @@ final class PhabricatorTokenGivenQuery
return array(); return array();
} }
$objects = id(new PhabricatorObjectHandleData($object_phids)) $objects = id(new PhabricatorObjectQuery())
->setViewer($this->getViewer()) ->setViewer($this->getViewer())
->loadObjects(); ->withPHIDs($object_phids)
->execute();
foreach ($results as $key => $result) { foreach ($results as $key => $result) {
$phid = $result->getObjectPHID(); $phid = $result->getObjectPHID();

View file

@ -19,9 +19,10 @@ final class PhabricatorTokenReceiverQuery
} }
public function willFilterPage(array $phids) { public function willFilterPage(array $phids) {
$objects = id(new PhabricatorObjectHandleData($phids)) $objects = id(new PhabricatorObjectQuery())
->setViewer($this->getViewer()) ->setViewer($this->getViewer())
->loadObjects(); ->withPHIDs($phids)
->execute();
// Reorder the objects in the input order. // Reorder the objects in the input order.
$objects = array_select_keys($objects, $phids); $objects = array_select_keys($objects, $phids);

View file

@ -19,9 +19,6 @@ final class PhabricatorApplicationTransactionCommentEditController
->executeOne(); ->executeOne();
if (!$xaction) { if (!$xaction) {
// TODO: This may also mean you don't have permission to edit the object,
// but we can't make that distinction via PhabricatorObjectHandleData
// at the moment.
return new Aphront404Response(); return new Aphront404Response();
} }
@ -32,7 +29,10 @@ final class PhabricatorApplicationTransactionCommentEditController
} }
$obj_phid = $xaction->getObjectPHID(); $obj_phid = $xaction->getObjectPHID();
$obj_handle = PhabricatorObjectHandleData::loadOneHandle($obj_phid, $user); $obj_handle = id(new PhabricatorHandleQuery())
->setViewer($user)
->withPHIDs(array($obj_phid))
->executeOne();
if ($request->isDialogFormPost()) { if ($request->isDialogFormPost()) {
$text = $request->getStr('text'); $text = $request->getStr('text');

View file

@ -19,9 +19,6 @@ final class PhabricatorApplicationTransactionCommentHistoryController
->executeOne(); ->executeOne();
if (!$xaction) { if (!$xaction) {
// TODO: This may also mean you don't have permission to edit the object,
// but we can't make that distinction via PhabricatorObjectHandleData
// at the moment.
return new Aphront404Response(); return new Aphront404Response();
} }
@ -53,7 +50,10 @@ final class PhabricatorApplicationTransactionCommentHistoryController
} }
$obj_phid = $xaction->getObjectPHID(); $obj_phid = $xaction->getObjectPHID();
$obj_handle = PhabricatorObjectHandleData::loadOneHandle($obj_phid, $user); $obj_handle = id(new PhabricatorHandleQuery())
->setViewer($user)
->withPHIDs(array($obj_phid))
->executeOne();
$view = id(new PhabricatorApplicationTransactionView()) $view = id(new PhabricatorApplicationTransactionView())
->setUser($user) ->setUser($user)

View file

@ -535,9 +535,10 @@ abstract class PhabricatorApplicationTransactionEditor
$handles = array(); $handles = array();
$merged = array_mergev($phids); $merged = array_mergev($phids);
if ($merged) { if ($merged) {
$handles = id(new PhabricatorObjectHandleData($merged)) $handles = id(new PhabricatorHandleQuery())
->setViewer($this->requireActor()) ->setViewer($this->requireActor())
->loadHandles(); ->withPHIDs($merged)
->execute();
} }
foreach ($xactions as $key => $xaction) { foreach ($xactions as $key => $xaction) {
$xaction->setHandles(array_select_keys($handles, $phids[$key])); $xaction->setHandles(array_select_keys($handles, $phids[$key]));
@ -1084,9 +1085,10 @@ abstract class PhabricatorApplicationTransactionEditor
$email_cc = array_unique($this->getMailCC($object)); $email_cc = array_unique($this->getMailCC($object));
$phids = array_merge($email_to, $email_cc); $phids = array_merge($email_to, $email_cc);
$handles = id(new PhabricatorObjectHandleData($phids)) $handles = id(new PhabricatorHandleQuery())
->setViewer($this->requireActor()) ->setViewer($this->requireActor())
->loadHandles(); ->withPHIDs($phids)
->execute();
$template = $this->buildMailTemplate($object); $template = $this->buildMailTemplate($object);
$body = $this->buildMailBody($object, $xactions); $body = $this->buildMailBody($object, $xactions);

View file

@ -100,9 +100,10 @@ abstract class PhabricatorApplicationTransactionQuery
$handles = array(); $handles = array();
$merged = array_mergev($phids); $merged = array_mergev($phids);
if ($merged) { if ($merged) {
$handles = id(new PhabricatorObjectHandleData($merged)) $handles = id(new PhabricatorHandleQuery())
->setViewer($this->getViewer()) ->setViewer($this->getViewer())
->loadHandles(); ->withPHIDs($merged)
->execute();
} }
foreach ($xactions as $xaction) { foreach ($xactions as $xaction) {
$xaction->setHandles( $xaction->setHandles(

View file

@ -15,9 +15,10 @@ final class PHUIObjectItemListExample extends PhabricatorUIExample {
$request = $this->getRequest(); $request = $this->getRequest();
$user = $request->getUser(); $user = $request->getUser();
$handle = PhabricatorObjectHandleData::loadOneHandle( $handle = id(new PhabricatorHandleQuery())
$user->getPHID(), ->setViewer($user)
$user); ->withPHIDs(array($user->getPHID()))
->executeOne();
$out = array(); $out = array();
@ -231,7 +232,7 @@ final class PHUIObjectItemListExample extends PhabricatorUIExample {
id(new PHUIObjectItemView()) id(new PHUIObjectItemView())
->setHeader(pht('Ace of Hearts')) ->setHeader(pht('Ace of Hearts'))
->setSubHead( ->setSubHead(
pht('This is the most powerful card in the game "Hearts".')) pht('This is a powerful card in the game "Hearts".'))
->setHref('#') ->setHref('#')
->addAttribute(pht('Suit: Hearts')) ->addAttribute(pht('Suit: Hearts'))
->addAttribute(pht('Rank: Ace')) ->addAttribute(pht('Rank: Ace'))

View file

@ -15,9 +15,10 @@ final class PhabricatorTimelineExample extends PhabricatorUIExample {
$request = $this->getRequest(); $request = $this->getRequest();
$user = $request->getUser(); $user = $request->getUser();
$handle = PhabricatorObjectHandleData::loadOneHandle( $handle = id(new PhabricatorHandleQuery())
$user->getPHID(), ->setViewer($user)
$user); ->withPHIDs(array($user->getPHID()))
->executeOne();
$events = array(); $events = array();

View file

@ -220,9 +220,10 @@ final class PhabricatorEdgeQuery extends PhabricatorQuery {
* *
* // Gets all of the destinations. * // Gets all of the destinations.
* $all_phids = $query->getDestinationPHIDs(); * $all_phids = $query->getDestinationPHIDs();
* $handles = id(new PhabricatorObjectHandleData($all_phids)) * $handles = id(new PhabricatorHandleQuery())
* ->setViewer($viewer) * ->setViewer($viewer)
* ->loadHandles(); * ->withPHIDs($all_phids)
* ->execute();
* *
* foreach ($objects as $object) { * foreach ($objects as $object) {
* // Get all of the destinations for the given object. * // Get all of the destinations for the given object.