1
0
Fork 0
mirror of https://we.phorge.it/source/phorge.git synced 2024-11-23 07:12: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',
'PhabricatorObjectHandle' => 'applications/phid/PhabricatorObjectHandle.php',
'PhabricatorObjectHandleConstants' => 'applications/phid/handle/const/PhabricatorObjectHandleConstants.php',
'PhabricatorObjectHandleData' => 'applications/phid/handle/PhabricatorObjectHandleData.php',
'PhabricatorObjectHandleStatus' => 'applications/phid/handle/const/PhabricatorObjectHandleStatus.php',
'PhabricatorObjectListView' => 'view/control/PhabricatorObjectListView.php',
'PhabricatorObjectMailReceiver' => 'applications/metamta/receiver/PhabricatorObjectMailReceiver.php',

View file

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

View file

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

View file

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

View file

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

View file

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

View file

@ -97,9 +97,10 @@ final class ConduitAPI_differential_getcommitmessage_Method
$aux_phids[$field_key] = $field->getRequiredHandlePHIDsForCommitMessage();
}
$phids = array_unique(array_mergev($aux_phids));
$handles = id(new PhabricatorObjectHandleData($phids))
$handles = id(new PhabricatorHandleQuery())
->setViewer($request->getUser())
->loadHandles();
->withPHIDs($phids)
->execute();
foreach ($aux_fields as $field_key => $field) {
$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_phids = $revision->loadCommitPHIDs();
$handles = id(new PhabricatorObjectHandleData($commit_phids))
$handles = id(new PhabricatorHandleQuery())
->setViewer($request->getUser())
->loadHandles();
->withPHIDs($commit_phids)
->execute();
foreach ($commit_phids as $commit_phid) {
$commit_dicts[] = array(

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

@ -98,9 +98,10 @@ final class DifferentialCommentMail extends DifferentialMail {
array());
$load = array_merge($m_reviewers, $m_cc);
if ($load) {
$handles = id(new PhabricatorObjectHandleData($load))
$handles = id(new PhabricatorHandleQuery())
->setViewer($this->getActor())
->loadHandles();
->withPHIDs($load)
->execute();
if ($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);
$reason_phids = ipull($raw, 'reasonPHID');
$reason_handles = id(new PhabricatorObjectHandleData($reason_phids))
$reason_handles = id(new PhabricatorHandleQuery())
->setViewer($this->getActor())
->loadHandles();
->withPHIDs($reason_phids)
->execute();
$explicit_cc = array();
foreach ($raw as $relation) {
@ -173,12 +174,14 @@ abstract class DifferentialMail extends PhabricatorMail {
}
$phids = array_keys($phids);
$handles = id(new PhabricatorObjectHandleData($phids))
$handles = id(new PhabricatorHandleQuery())
->setViewer($this->getActor())
->loadHandles();
$objects = id(new PhabricatorObjectHandleData($phids))
->withPHIDs($phids)
->execute();
$objects = id(new PhabricatorObjectQuery())
->setViewer($this->getActor())
->loadObjects();
->withPHIDs($phids)
->execute();
$to_handles = array_select_keys($handles, $to_phids);
$cc_handles = array_select_keys($handles, $cc_phids);

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

@ -511,7 +511,7 @@ final class ManiphestTaskQuery
}
$projects = id(new PhabricatorProjectQuery())
->setViewer($this->viewer)
->setViewer($this->getViewer())
->withMemberPHIDs($this->anyUserProjectPHIDs)
->execute();
$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
// PhabricatorPolicyQuery (T603).
$handles = id(new PhabricatorObjectHandleData(array_keys($project_phids)))
->setViewer(PhabricatorUser::getOmnipotentUser())
->loadHandles();
$handles = id(new PhabricatorHandleQuery())
->setViewer($this->getViewer())
->withPHIDs(array_keys($project_phids))
->execute();
$max = 1;
foreach ($handles as $handle) {

View file

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

View file

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

View file

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

View file

@ -97,9 +97,10 @@ final class ManiphestHovercardEventListener extends PhutilEventListener {
}
protected function loadHandles(array $phids, $viewer) {
return id(new PhabricatorObjectHandleData($phids))
return id(new PhabricatorHandleQuery())
->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
// lists, e.g.)
$handles = id(new PhabricatorObjectHandleData(array_keys($ccs)))
$handles = id(new PhabricatorHandleQuery())
->setViewer(PhabricatorUser::getOmnipotentUser())
->loadHandles();
->withPHIDs(array_keys($ccs))
->execute();
foreach ($ccs as $cc => $time) {
$doc->addRelationship(
PhabricatorSearchRelationship::RELATIONSHIP_SUBSCRIBER,

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

@ -93,47 +93,10 @@ final class PhameBlog extends PhameDAO
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() {
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) {
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
* 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
* PHIDs.
*

View file

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

View file

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

View file

@ -28,9 +28,10 @@ final class ConduitAPI_phid_query_Method
$phids = $request->getValue('phids');
$handles = id(new PhabricatorObjectHandleData($phids))
$handles = id(new PhabricatorHandleQuery())
->setViewer($request->getUser())
->loadHandles();
->withPHIDs($phids)
->execute();
$result = array();
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.
$mock->setViewPolicy($v_view);
$handles = id(new PhabricatorObjectHandleData($v_cc))
$handles = id(new PhabricatorHandleQuery())
->setViewer($user)
->loadHandles();
->withPHIDs($v_cc)
->execute();
$cc_tokens = mpull($handles, 'getFullName', 'getPHID');

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

@ -32,17 +32,15 @@ final class PhabricatorSubscriptionsEditController
$user = $request->getUser();
$phid = $this->phid;
// TODO: This is a policy test because `loadObjects()` is not currently
// 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)))
$handle = id(new PhabricatorHandleQuery())
->setViewer($user)
->loadObjects();
$object = idx($objects, $phid);
->withPHIDs(array($phid))
->executeOne();
$object = id(new PhabricatorObjectQuery())
->setViewer($user)
->withPHIDs(array($phid))
->executeOne();
if (!($object instanceof PhabricatorSubscribableInterface)) {
return $this->buildErrorResponse(

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

@ -19,9 +19,6 @@ final class PhabricatorApplicationTransactionCommentEditController
->executeOne();
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();
}
@ -32,7 +29,10 @@ final class PhabricatorApplicationTransactionCommentEditController
}
$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()) {
$text = $request->getStr('text');

View file

@ -19,9 +19,6 @@ final class PhabricatorApplicationTransactionCommentHistoryController
->executeOne();
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();
}
@ -53,7 +50,10 @@ final class PhabricatorApplicationTransactionCommentHistoryController
}
$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())
->setUser($user)

View file

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

View file

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

View file

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

View file

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

View file

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