diff --git a/src/applications/base/controller/PhabricatorController.php b/src/applications/base/controller/PhabricatorController.php --- a/src/applications/base/controller/PhabricatorController.php +++ b/src/applications/base/controller/PhabricatorController.php @@ -426,20 +426,6 @@ return $response; } - protected function getHandle($phid) { - if (empty($this->handles[$phid])) { - throw new Exception( - "Attempting to access handle which wasn't loaded: {$phid}"); - } - return $this->handles[$phid]; - } - - protected function loadHandles(array $phids) { - $phids = array_filter($phids); - $this->handles = $this->loadViewerHandles($phids); - return $this; - } - protected function loadViewerHandles(array $phids) { return id(new PhabricatorHandleQuery()) ->setViewer($this->getRequest()->getUser()) diff --git a/src/applications/countdown/controller/PhabricatorCountdownViewController.php b/src/applications/countdown/controller/PhabricatorCountdownViewController.php --- a/src/applications/countdown/controller/PhabricatorCountdownViewController.php +++ b/src/applications/countdown/controller/PhabricatorCountdownViewController.php @@ -101,7 +101,6 @@ PhabricatorActionListView $actions) { $viewer = $this->getViewer(); - $handles = $viewer->loadHandles(array($countdown->getAuthorPHID())); $view = id(new PHUIPropertyListView()) ->setUser($viewer) @@ -109,7 +108,7 @@ $view->addProperty( pht('Author'), - $handles[$countdown->getAuthorPHID()]->renderLink()); + $viewer->renderHandle($countdown->getAuthorPHID())); return $view; } diff --git a/src/applications/dashboard/controller/PhabricatorDashboardInstallController.php b/src/applications/dashboard/controller/PhabricatorDashboardInstallController.php --- a/src/applications/dashboard/controller/PhabricatorDashboardInstallController.php +++ b/src/applications/dashboard/controller/PhabricatorDashboardInstallController.php @@ -50,11 +50,6 @@ 'applicationClass', 'PhabricatorHomeApplication'); - $handles = $this->loadHandles(array( - $object_phid, - $installer_phid, - )); - if ($request->isFormPost()) { $dashboard_install = id(new PhabricatorDashboardInstall()) ->loadOneWhere( @@ -121,7 +116,7 @@ phutil_tag( 'strong', array(), - $this->getHandle($object_phid)->getName()))); + $viewer->renderHandle($object_phid)))); } break; default: diff --git a/src/applications/dashboard/controller/PhabricatorDashboardUninstallController.php b/src/applications/dashboard/controller/PhabricatorDashboardUninstallController.php --- a/src/applications/dashboard/controller/PhabricatorDashboardUninstallController.php +++ b/src/applications/dashboard/controller/PhabricatorDashboardUninstallController.php @@ -53,7 +53,6 @@ } $installer_phid = $viewer->getPHID(); - $handles = $this->loadHandles(array($object_phid, $installer_phid)); if ($request->isFormPost()) { $dashboard_install->delete(); @@ -83,6 +82,8 @@ $object_phid, $installer_phid) { + $viewer = $this->getViewer(); + $body = array(); switch ($application_class) { case 'PhabricatorHomeApplication': @@ -106,7 +107,7 @@ pht( 'Are you sure you want to uninstall this dashboard as the home '. 'page for %s?', - $this->getHandle($object_phid)->getName())); + $viewer->renderHandle($object_phid))); } break; } diff --git a/src/applications/diffusion/controller/DiffusionCommitController.php b/src/applications/diffusion/controller/DiffusionCommitController.php --- a/src/applications/diffusion/controller/DiffusionCommitController.php +++ b/src/applications/diffusion/controller/DiffusionCommitController.php @@ -1021,9 +1021,7 @@ private function renderAuditStatusView(array $audit_requests) { assert_instances_of($audit_requests, 'PhabricatorRepositoryAuditRequest'); - - $phids = mpull($audit_requests, 'getAuditorPHID'); - $this->loadHandles($phids); + $viewer = $this->getViewer(); $authority_map = array_fill_keys($this->auditAuthorityPHIDs, true); @@ -1043,7 +1041,7 @@ $item->setNote($note); $auditor_phid = $request->getAuditorPHID(); - $target = $this->getHandle($auditor_phid)->renderLink(); + $target = $viewer->renderHandle($auditor_phid); $item->setTarget($target); if (isset($authority_map[$auditor_phid])) { diff --git a/src/applications/diffusion/controller/DiffusionPushEventViewController.php b/src/applications/diffusion/controller/DiffusionPushEventViewController.php --- a/src/applications/diffusion/controller/DiffusionPushEventViewController.php +++ b/src/applications/diffusion/controller/DiffusionPushEventViewController.php @@ -70,9 +70,6 @@ private function buildPropertyList(PhabricatorRepositoryPushEvent $event) { $viewer = $this->getRequest()->getUser(); - - $this->loadHandles(array($event->getPusherPHID())); - $view = new PHUIPropertyListView(); $view->addProperty( @@ -81,7 +78,7 @@ $view->addProperty( pht('Pushed By'), - $this->getHandle($event->getPusherPHID())->renderLink()); + $viewer->renderHandle($event->getPusherPHID())); $view->addProperty( pht('Pushed Via'), diff --git a/src/applications/fund/controller/FundInitiativeViewController.php b/src/applications/fund/controller/FundInitiativeViewController.php --- a/src/applications/fund/controller/FundInitiativeViewController.php +++ b/src/applications/fund/controller/FundInitiativeViewController.php @@ -87,19 +87,14 @@ $owner_phid = $initiative->getOwnerPHID(); $merchant_phid = $initiative->getMerchantPHID(); - $this->loadHandles( - array( - $owner_phid, - $merchant_phid, - )); $view->addProperty( pht('Owner'), - $this->getHandle($owner_phid)->renderLink()); + $viewer->renderHandle($owner_phid)); $view->addProperty( pht('Payable to Merchant'), - $this->getHandle($merchant_phid)->renderLink()); + $viewer->renderHandle($merchant_phid)); $view->addProperty( pht('Total Funding'), diff --git a/src/applications/herald/controller/HeraldRuleViewController.php b/src/applications/herald/controller/HeraldRuleViewController.php --- a/src/applications/herald/controller/HeraldRuleViewController.php +++ b/src/applications/herald/controller/HeraldRuleViewController.php @@ -115,8 +115,6 @@ $viewer = $this->getRequest()->getUser(); - $handles = $viewer->loadHandles(HeraldAdapter::getHandlePHIDs($rule)); - $view = id(new PHUIPropertyListView()) ->setUser($viewer) ->setObject($rule) @@ -129,10 +127,9 @@ if ($rule->isPersonalRule()) { $view->addProperty( pht('Author'), - $this->getHandle($rule->getAuthorPHID())->renderLink()); + $viewer->renderHandle($rule->getAuthorPHID())); } - $adapter = HeraldAdapter::getAdapterForContentType($rule->getContentType()); if ($adapter) { $view->addProperty( @@ -144,7 +141,7 @@ if ($rule->isObjectRule()) { $view->addProperty( pht('Trigger Object'), - $this->getHandle($rule->getTriggerObjectPHID())->renderLink()); + $viewer->renderHandle($rule->getTriggerObjectPHID())); } $view->invokeWillRenderEvent(); @@ -153,6 +150,7 @@ pht('Rule Description'), PHUIPropertyListView::ICON_SUMMARY); + $handles = $viewer->loadHandles(HeraldAdapter::getHandlePHIDs($rule)); $view->addTextContent($adapter->renderRuleAsText($rule, $handles)); } diff --git a/src/applications/legalpad/controller/LegalpadDocumentManageController.php b/src/applications/legalpad/controller/LegalpadDocumentManageController.php --- a/src/applications/legalpad/controller/LegalpadDocumentManageController.php +++ b/src/applications/legalpad/controller/LegalpadDocumentManageController.php @@ -33,15 +33,6 @@ $document->getPHID()); $document_body = $document->getDocumentBody(); - $phids = array(); - $phids[] = $document_body->getCreatorPHID(); - foreach ($subscribers as $subscriber) { - $phids[] = $subscriber; - } - foreach ($document->getContributors() as $contributor) { - $phids[] = $contributor; - } - $this->loadHandles($phids); $engine = id(new PhabricatorMarkupEngine()) ->setViewer($user); @@ -167,21 +158,19 @@ $properties->addProperty( pht('Updated By'), - $this->getHandle( - $document->getDocumentBody()->getCreatorPHID())->renderLink()); + $user->renderHandle($document->getDocumentBody()->getCreatorPHID())); $properties->addProperty( pht('Versions'), $document->getVersions()); - $contributor_view = array(); - foreach ($document->getContributors() as $contributor) { - $contributor_view[] = $this->getHandle($contributor)->renderLink(); + if ($document->getContributors()) { + $properties->addProperty( + pht('Contributors'), + $user + ->renderHandleList($document->getContributors()) + ->setAsInline(true)); } - $contributor_view = phutil_implode_html(', ', $contributor_view); - $properties->addProperty( - pht('Contributors'), - $contributor_view); $properties->invokeWillRenderEvent(); diff --git a/src/applications/macro/controller/PhabricatorMacroViewController.php b/src/applications/macro/controller/PhabricatorMacroViewController.php --- a/src/applications/macro/controller/PhabricatorMacroViewController.php +++ b/src/applications/macro/controller/PhabricatorMacroViewController.php @@ -150,6 +150,7 @@ private function buildPropertyView( PhabricatorFileImageMacro $macro, PhabricatorActionListView $actions) { + $viewer = $this->getViewer(); $view = id(new PHUIPropertyListView()) ->setUser($this->getRequest()->getUser()) @@ -167,10 +168,9 @@ $audio_phid = $macro->getAudioPHID(); if ($audio_phid) { - $this->loadHandles(array($audio_phid)); $view->addProperty( pht('Audio'), - $this->getHandle($audio_phid)->renderLink()); + $viewer->renderHandle($audio_phid)); } $view->invokeWillRenderEvent(); diff --git a/src/applications/paste/controller/PhabricatorPasteViewController.php b/src/applications/paste/controller/PhabricatorPasteViewController.php --- a/src/applications/paste/controller/PhabricatorPasteViewController.php +++ b/src/applications/paste/controller/PhabricatorPasteViewController.php @@ -58,14 +58,6 @@ ->execute(); $fork_phids = mpull($forks, 'getPHID'); - $this->loadHandles( - array_merge( - array( - $paste->getAuthorPHID(), - $paste->getParentPHID(), - ), - $fork_phids)); - $header = $this->buildHeaderView($paste); $actions = $this->buildActionView($user, $paste, $file); $properties = $this->buildPropertyView($paste, $fork_phids, $actions); diff --git a/src/applications/phame/controller/PhameController.php b/src/applications/phame/controller/PhameController.php --- a/src/applications/phame/controller/PhameController.php +++ b/src/applications/phame/controller/PhameController.php @@ -33,16 +33,24 @@ $nodata) { assert_instances_of($posts, 'PhamePost'); - $stories = array(); + $handle_phids = array(); + foreach ($posts as $post) { + $handle_phids[] = $post->getBloggerPHID(); + if ($post->getBlog()) { + $handle_phids[] = $post->getBlog()->getPHID(); + } + } + $handles = $viewer->loadHandles($handle_phids); + $stories = array(); foreach ($posts as $post) { - $blogger = $this->getHandle($post->getBloggerPHID())->renderLink(); - $blogger_uri = $this->getHandle($post->getBloggerPHID())->getURI(); - $blogger_image = $this->getHandle($post->getBloggerPHID())->getImageURI(); + $blogger = $handles[$post->getBloggerPHID()]->renderLink(); + $blogger_uri = $handles[$post->getBloggerPHID()]->getURI(); + $blogger_image = $handles[$post->getBloggerPHID()]->getImageURI(); $blog = null; if ($post->getBlog()) { - $blog = $this->getHandle($post->getBlog()->getPHID())->renderLink(); + $blog = $handles[$post->getBlog()->getPHID()]->renderLink(); } $phame_post = ''; diff --git a/src/applications/phame/controller/blog/PhameBlogViewController.php b/src/applications/phame/controller/blog/PhameBlogViewController.php --- a/src/applications/phame/controller/blog/PhameBlogViewController.php +++ b/src/applications/phame/controller/blog/PhameBlogViewController.php @@ -35,11 +35,6 @@ ->setUser($user) ->setPolicyObject($blog); - $handle_phids = array_merge( - mpull($posts, 'getBloggerPHID'), - mpull($posts, 'getBlogPHID')); - $this->loadHandles($handle_phids); - $actions = $this->renderActions($blog, $user); $properties = $this->renderProperties($blog, $user, $actions); $post_list = $this->renderPostList( diff --git a/src/applications/phame/controller/post/PhamePostListController.php b/src/applications/phame/controller/post/PhamePostListController.php --- a/src/applications/phame/controller/post/PhamePostListController.php +++ b/src/applications/phame/controller/post/PhamePostListController.php @@ -62,11 +62,6 @@ $posts = $query->executeWithCursorPager($pager); - $handle_phids = array_merge( - mpull($posts, 'getBloggerPHID'), - mpull($posts, 'getBlogPHID')); - $this->loadHandles($handle_phids); - require_celerity_resource('phame-css'); $post_list = $this->renderPostList($posts, $user, $nodata); $post_list = id(new PHUIBoxView()) diff --git a/src/applications/phame/controller/post/PhamePostViewController.php b/src/applications/phame/controller/post/PhamePostViewController.php --- a/src/applications/phame/controller/post/PhamePostViewController.php +++ b/src/applications/phame/controller/post/PhamePostViewController.php @@ -23,11 +23,6 @@ $nav = $this->renderSideNavFilterView(); - $this->loadHandles( - array( - $post->getBlogPHID(), - $post->getBloggerPHID(), - )); $actions = $this->renderActions($post, $user); $properties = $this->renderProperties($post, $user, $actions); @@ -168,13 +163,11 @@ $properties->addProperty( pht('Blog'), - $post->getBlogPHID() - ? $this->getHandle($post->getBlogPHID())->renderLink() - : null); + $user->renderHandle($post->getBlogPHID())); $properties->addProperty( pht('Blogger'), - $this->getHandle($post->getBloggerPHID())->renderLink()); + $user->renderHandle($post->getBloggerPHID())); $properties->addProperty( pht('Published'), diff --git a/src/applications/phortune/controller/PhortuneAccountListController.php b/src/applications/phortune/controller/PhortuneAccountListController.php --- a/src/applications/phortune/controller/PhortuneAccountListController.php +++ b/src/applications/phortune/controller/PhortuneAccountListController.php @@ -35,7 +35,6 @@ 'accounts are used to make purchases.')); foreach ($accounts as $account) { - $this->loadHandles($account->getMemberPHIDs()); $item = id(new PHUIObjectItemView()) ->setObjectName(pht('Account %d', $account->getID())) ->setHeader($account->getName()) diff --git a/src/applications/phriction/controller/PhrictionDocumentController.php b/src/applications/phriction/controller/PhrictionDocumentController.php --- a/src/applications/phriction/controller/PhrictionDocumentController.php +++ b/src/applications/phriction/controller/PhrictionDocumentController.php @@ -250,13 +250,9 @@ ->setUser($viewer) ->setObject($document); - $phids = array($content->getAuthorPHID()); - - $this->loadHandles($phids); - $view->addProperty( pht('Last Author'), - $this->getHandle($content->getAuthorPHID())->renderLink()); + $viewer->renderHandle($content->getAuthorPHID())); $age = time() - $content->getDateCreated(); $age = floor($age / (60 * 60 * 24)); diff --git a/src/applications/ponder/controller/PonderQuestionViewController.php b/src/applications/ponder/controller/PonderQuestionViewController.php --- a/src/applications/ponder/controller/PonderQuestionViewController.php +++ b/src/applications/ponder/controller/PonderQuestionViewController.php @@ -141,15 +141,13 @@ ->setObject($question) ->setActionList($actions); - $this->loadHandles(array($question->getAuthorPHID())); - $view->addProperty( pht('Status'), PonderQuestionStatus::getQuestionStatusFullName($question->getStatus())); $view->addProperty( pht('Author'), - $this->getHandle($question->getAuthorPHID())->renderLink()); + $viewer->renderHandle($question->getAuthorPHID())); $view->addProperty( pht('Created'), @@ -221,9 +219,6 @@ $out = array(); - $phids = mpull($answers, 'getAuthorPHID'); - $this->loadHandles($phids); - $xactions = id(new PonderAnswerTransactionQuery()) ->setViewer($viewer) ->withTransactionTypes(array(PhabricatorTransactions::TYPE_COMMENT)) @@ -253,7 +248,7 @@ $out[] = id(new PhabricatorAnchorView()) ->setAnchorName("A$id"); $header = id(new PHUIHeaderView()) - ->setHeader($this->getHandle($author_phid)->getFullName()); + ->setHeader($viewer->renderHandle($author_phid)); $actions = $this->buildAnswerActions($answer); $properties = $this->buildAnswerProperties($answer, $actions);