diff --git a/src/__phutil_library_map__.php b/src/__phutil_library_map__.php index 17e81b566a..95790301d2 100644 --- a/src/__phutil_library_map__.php +++ b/src/__phutil_library_map__.php @@ -1001,6 +1001,7 @@ phutil_register_library_map(array( 'PhabricatorMacroTransactionQuery' => 'applications/macro/query/PhabricatorMacroTransactionQuery.php', 'PhabricatorMacroTransactionType' => 'applications/macro/constants/PhabricatorMacroTransactionType.php', 'PhabricatorMacroViewController' => 'applications/macro/controller/PhabricatorMacroViewController.php', + 'PhabricatorMail' => 'applications/metamta/PhabricatorMail.php', 'PhabricatorMailImplementationAdapter' => 'applications/metamta/adapter/PhabricatorMailImplementationAdapter.php', 'PhabricatorMailImplementationAmazonSESAdapter' => 'applications/metamta/adapter/PhabricatorMailImplementationAmazonSESAdapter.php', 'PhabricatorMailImplementationPHPMailerAdapter' => 'applications/metamta/adapter/PhabricatorMailImplementationPHPMailerAdapter.php', @@ -1846,6 +1847,7 @@ phutil_register_library_map(array( 'DifferentialLinesFieldSpecification' => 'DifferentialFieldSpecification', 'DifferentialLintFieldSpecification' => 'DifferentialFieldSpecification', 'DifferentialLocalCommitsView' => 'AphrontView', + 'DifferentialMail' => 'PhabricatorMail', 'DifferentialManiphestTasksFieldSpecification' => 'DifferentialFieldSpecification', 'DifferentialNewDiffMail' => 'DifferentialReviewRequestMail', 'DifferentialParseRenderTestCase' => 'PhabricatorTestCase', @@ -2120,6 +2122,7 @@ phutil_register_library_map(array( 'OwnersPackageReplyHandler' => 'PhabricatorMailReplyHandler', 'PackageCreateMail' => 'PackageMail', 'PackageDeleteMail' => 'PackageMail', + 'PackageMail' => 'PhabricatorMail', 'PackageModifyMail' => 'PackageMail', 'Phabricator404Controller' => 'PhabricatorController', 'PhabricatorAWSConfigOptions' => 'PhabricatorApplicationConfigOptions', @@ -3017,6 +3020,7 @@ phutil_register_library_map(array( 'PonderController' => 'PhabricatorController', 'PonderDAO' => 'PhabricatorLiskDAO', 'PonderFeedController' => 'PonderController', + 'PonderMail' => 'PhabricatorMail', 'PonderMentionMail' => 'PonderMail', 'PonderPostBodyView' => 'AphrontView', 'PonderQuestion' => diff --git a/src/applications/audit/editor/PhabricatorAuditCommentEditor.php b/src/applications/audit/editor/PhabricatorAuditCommentEditor.php index f001b4b43f..aeb8c30268 100644 --- a/src/applications/audit/editor/PhabricatorAuditCommentEditor.php +++ b/src/applications/audit/editor/PhabricatorAuditCommentEditor.php @@ -437,7 +437,9 @@ final class PhabricatorAuditCommentEditor extends PhabricatorEditor { $email_cc = array_keys($email_cc); $phids = array_merge($email_to, $email_cc); - $handles = id(new PhabricatorObjectHandleData($phids))->loadHandles(); + $handles = id(new PhabricatorObjectHandleData($phids)) + ->setViewer($this->getActor()) + ->loadHandles(); // NOTE: Always set $is_new to false, because the "first" mail in the // thread is the Herald notification of the commit. diff --git a/src/applications/differential/DifferentialReplyHandler.php b/src/applications/differential/DifferentialReplyHandler.php index 9a3e3845f1..aa8d09e5e6 100644 --- a/src/applications/differential/DifferentialReplyHandler.php +++ b/src/applications/differential/DifferentialReplyHandler.php @@ -157,6 +157,7 @@ class DifferentialReplyHandler extends PhabricatorMailReplyHandler { $ex, $error_body); + $exception_mail->setActor($this->getActor()); $exception_mail->setToPHIDs(array($this->getActor()->getPHID())); $exception_mail->send(); diff --git a/src/applications/differential/conduit/ConduitAPI_differential_getcommitmessage_Method.php b/src/applications/differential/conduit/ConduitAPI_differential_getcommitmessage_Method.php index 30e4c2126e..a7b48b025f 100644 --- a/src/applications/differential/conduit/ConduitAPI_differential_getcommitmessage_Method.php +++ b/src/applications/differential/conduit/ConduitAPI_differential_getcommitmessage_Method.php @@ -49,6 +49,7 @@ final class ConduitAPI_differential_getcommitmessage_Method ->getFieldSpecifications(); foreach ($aux_fields as $key => $aux_field) { + $aux_field->setUser($request->getUser()); $aux_field->setRevision($revision); if (!$aux_field->shouldAppearOnCommitMessage()) { unset($aux_fields[$key]); @@ -87,7 +88,9 @@ final class ConduitAPI_differential_getcommitmessage_Method $aux_phids[$field_key] = $field->getRequiredHandlePHIDsForCommitMessage(); } $phids = array_unique(array_mergev($aux_phids)); - $handles = id(new PhabricatorObjectHandleData($phids))->loadHandles(); + $handles = id(new PhabricatorObjectHandleData($phids)) + ->setViewer($request->getUser()) + ->loadHandles(); foreach ($aux_fields as $field_key => $field) { $field->setHandles(array_select_keys($handles, $aux_phids[$field_key])); } diff --git a/src/applications/differential/conduit/ConduitAPI_differential_getrevision_Method.php b/src/applications/differential/conduit/ConduitAPI_differential_getrevision_Method.php index 57568c7bbf..e2ce4aeac4 100644 --- a/src/applications/differential/conduit/ConduitAPI_differential_getrevision_Method.php +++ b/src/applications/differential/conduit/ConduitAPI_differential_getrevision_Method.php @@ -61,6 +61,7 @@ final class ConduitAPI_differential_getrevision_Method $commit_dicts = array(); $commit_phids = $revision->loadCommitPHIDs(); $handles = id(new PhabricatorObjectHandleData($commit_phids)) + ->setViewer($request->getUser()) ->loadHandles(); foreach ($commit_phids as $commit_phid) { @@ -70,7 +71,9 @@ final class ConduitAPI_differential_getrevision_Method ); } - $auxiliary_fields = $this->loadAuxiliaryFields($revision); + $auxiliary_fields = $this->loadAuxiliaryFields( + $revision, + $request->getUser()); $dict = array( 'id' => $revision->getID(), @@ -94,10 +97,13 @@ final class ConduitAPI_differential_getrevision_Method return $dict; } - private function loadAuxiliaryFields(DifferentialRevision $revision) { + private function loadAuxiliaryFields( + DifferentialRevision $revision, + PhabricatorUser $user) { $aux_fields = DifferentialFieldSelector::newSelector() ->getFieldSpecifications(); foreach ($aux_fields as $key => $aux_field) { + $aux_field->setUser($user); if (!$aux_field->shouldAppearOnConduitView()) { unset($aux_fields[$key]); } diff --git a/src/applications/differential/conduit/ConduitAPI_differential_parsecommitmessage_Method.php b/src/applications/differential/conduit/ConduitAPI_differential_parsecommitmessage_Method.php index 0766c2b27b..10e2b35468 100644 --- a/src/applications/differential/conduit/ConduitAPI_differential_parsecommitmessage_Method.php +++ b/src/applications/differential/conduit/ConduitAPI_differential_parsecommitmessage_Method.php @@ -36,10 +36,10 @@ final class ConduitAPI_differential_parsecommitmessage_Method ->getFieldSpecifications(); foreach ($aux_fields as $key => $aux_field) { + $aux_field->setUser($request->getUser()); if (!$aux_field->shouldAppearOnCommitMessage()) { unset($aux_fields[$key]); } - $aux_field->setUser($request->getUser()); } $aux_fields = mpull($aux_fields, null, 'getCommitMessageKey'); diff --git a/src/applications/differential/controller/DifferentialRevisionListController.php b/src/applications/differential/controller/DifferentialRevisionListController.php index 2d670623e5..35bc3fb802 100644 --- a/src/applications/differential/controller/DifferentialRevisionListController.php +++ b/src/applications/differential/controller/DifferentialRevisionListController.php @@ -430,7 +430,7 @@ final class DifferentialRevisionListController extends DifferentialController { $template = id(new DifferentialRevisionListView()) ->setUser($user) - ->setFields(DifferentialRevisionListView::getDefaultFields()); + ->setFields(DifferentialRevisionListView::getDefaultFields($user)); $views = array(); switch ($filter) { @@ -462,6 +462,7 @@ final class DifferentialRevisionListController extends DifferentialController { // looking at your own requests. if (in_array($user->getPHID(), $user_phids)) { $flags = id(new PhabricatorFlagQuery()) + ->setViewer($user) ->withOwnerPHIDs(array($user->getPHID())) ->withTypes(array(PhabricatorPHIDConstants::PHID_TYPE_DREV)) ->needHandles(true) diff --git a/src/applications/differential/controller/DifferentialRevisionViewController.php b/src/applications/differential/controller/DifferentialRevisionViewController.php index 1ccc60e33c..480a9441e4 100644 --- a/src/applications/differential/controller/DifferentialRevisionViewController.php +++ b/src/applications/differential/controller/DifferentialRevisionViewController.php @@ -846,10 +846,12 @@ final class DifferentialRevisionViewController extends DifferentialController { private function renderOtherRevisions(array $revisions) { assert_instances_of($revisions, 'DifferentialRevision'); + $user = $this->getRequest()->getUser(); + $view = id(new DifferentialRevisionListView()) ->setRevisions($revisions) - ->setFields(DifferentialRevisionListView::getDefaultFields()) - ->setUser($this->getRequest()->getUser()) + ->setFields(DifferentialRevisionListView::getDefaultFields($user)) + ->setUser($user) ->loadAssets(); $phids = $view->getRequiredHandlePHIDs(); diff --git a/src/applications/differential/editor/DifferentialCommentEditor.php b/src/applications/differential/editor/DifferentialCommentEditor.php index 8054b791c5..240deda2bc 100644 --- a/src/applications/differential/editor/DifferentialCommentEditor.php +++ b/src/applications/differential/editor/DifferentialCommentEditor.php @@ -553,6 +553,7 @@ final class DifferentialCommentEditor extends PhabricatorEditor { $phids = array($actor_phid); $handles = id(new PhabricatorObjectHandleData($phids)) + ->setViewer($this->getActor()) ->loadHandles(); $actor_handle = $handles[$actor_phid]; @@ -567,6 +568,7 @@ final class DifferentialCommentEditor extends PhabricatorEditor { $comment, $changesets, $inline_comments)) + ->setActor($this->getActor()) ->setExcludeMailRecipientPHIDs($this->getExcludeMailRecipientPHIDs()) ->setToPHIDs( array_merge( diff --git a/src/applications/differential/editor/DifferentialRevisionEditor.php b/src/applications/differential/editor/DifferentialRevisionEditor.php index 19f78bb9f8..00a7fba800 100644 --- a/src/applications/differential/editor/DifferentialRevisionEditor.php +++ b/src/applications/differential/editor/DifferentialRevisionEditor.php @@ -346,6 +346,7 @@ final class DifferentialRevisionEditor extends PhabricatorEditor { $phids = array($this->getActorPHID()); $handles = id(new PhabricatorObjectHandleData($phids)) + ->setViewer($this->getActor()) ->loadHandles(); $actor_handle = $handles[$this->getActorPHID()]; @@ -362,6 +363,7 @@ final class DifferentialRevisionEditor extends PhabricatorEditor { $revision, $actor_handle, $changesets)) + ->setActor($this->getActor()) ->setIsFirstMailAboutRevision($is_new) ->setIsFirstMailToRecipients($is_new) ->setComments($this->getComments()) @@ -456,6 +458,7 @@ final class DifferentialRevisionEditor extends PhabricatorEditor { $revision, $actor_handle, $changesets)) + ->setActor($this->getActor()) ->setIsFirstMailToRecipients(true) ->setToPHIDs(array_keys($add['ccs'])); } diff --git a/src/applications/differential/field/specification/DifferentialArcanistProjectFieldSpecification.php b/src/applications/differential/field/specification/DifferentialArcanistProjectFieldSpecification.php index 085c8b7824..ef8f346b97 100644 --- a/src/applications/differential/field/specification/DifferentialArcanistProjectFieldSpecification.php +++ b/src/applications/differential/field/specification/DifferentialArcanistProjectFieldSpecification.php @@ -47,7 +47,9 @@ final class DifferentialArcanistProjectFieldSpecification if ($diff) { $phid = $diff->getArcanistProjectPHID(); if ($phid) { - $handle = PhabricatorObjectHandleData::loadOneHandle($phid); + $handle = PhabricatorObjectHandleData::loadOneHandle( + $phid, + $this->getUser()); return "ARCANIST PROJECT\n ".$handle->getName(); } } diff --git a/src/applications/differential/field/specification/DifferentialManiphestTasksFieldSpecification.php b/src/applications/differential/field/specification/DifferentialManiphestTasksFieldSpecification.php index 3112f0f379..9ff4e8e860 100644 --- a/src/applications/differential/field/specification/DifferentialManiphestTasksFieldSpecification.php +++ b/src/applications/differential/field/specification/DifferentialManiphestTasksFieldSpecification.php @@ -163,6 +163,7 @@ final class DifferentialManiphestTasksFieldSpecification } $handles = id(new PhabricatorObjectHandleData($this->maniphestTasks)) + ->setViewer($this->getUser()) ->loadHandles(); $body = array(); $body[] = 'MANIPHEST TASKS'; diff --git a/src/applications/differential/field/specification/DifferentialReviewersFieldSpecification.php b/src/applications/differential/field/specification/DifferentialReviewersFieldSpecification.php index de6a89f05a..45a20da245 100644 --- a/src/applications/differential/field/specification/DifferentialReviewersFieldSpecification.php +++ b/src/applications/differential/field/specification/DifferentialReviewersFieldSpecification.php @@ -182,6 +182,7 @@ final class DifferentialReviewersFieldSpecification } $handles = id(new PhabricatorObjectHandleData($this->reviewers)) + ->setViewer($this->getUser()) ->loadHandles(); $handles = array_select_keys( $handles, diff --git a/src/applications/differential/mail/DifferentialCommentMail.php b/src/applications/differential/mail/DifferentialCommentMail.php index addd8f9a41..ef178a1d53 100644 --- a/src/applications/differential/mail/DifferentialCommentMail.php +++ b/src/applications/differential/mail/DifferentialCommentMail.php @@ -104,7 +104,9 @@ final class DifferentialCommentMail extends DifferentialMail { array()); $load = array_merge($m_reviewers, $m_cc); if ($load) { - $handles = id(new PhabricatorObjectHandleData($load))->loadHandles(); + $handles = id(new PhabricatorObjectHandleData($load)) + ->setViewer($this->getActor()) + ->loadHandles(); if ($m_reviewers) { $this->addedReviewers = $this->renderHandleList($handles, $m_reviewers); } diff --git a/src/applications/differential/mail/DifferentialMail.php b/src/applications/differential/mail/DifferentialMail.php index 30904ac5f6..12b6503144 100644 --- a/src/applications/differential/mail/DifferentialMail.php +++ b/src/applications/differential/mail/DifferentialMail.php @@ -1,6 +1,6 @@ setViewer($this->getActor()) ->loadHandles(); $explicit_cc = array(); @@ -172,8 +173,12 @@ abstract class DifferentialMail { } $phids = array_keys($phids); - $handles = id(new PhabricatorObjectHandleData($phids))->loadHandles(); - $objects = id(new PhabricatorObjectHandleData($phids))->loadObjects(); + $handles = id(new PhabricatorObjectHandleData($phids)) + ->setViewer($this->getActor()) + ->loadHandles(); + $objects = id(new PhabricatorObjectHandleData($phids)) + ->setViewer($this->getActor()) + ->loadObjects(); $to_handles = array_select_keys($handles, $to_phids); $cc_handles = array_select_keys($handles, $cc_phids); @@ -398,7 +403,7 @@ abstract class DifferentialMail { $body = array(); foreach ($aux_fields as $field) { - $field->setUser(id(new PhabricatorUser())->setPHID('PHID-USER-XXX')); + $field->setUser($this->getActor()); $field->setRevision($this->getRevision()); // TODO: Introduce and use getRequiredHandlePHIDsForMail() and load all // handles in prepareBody(). diff --git a/src/applications/differential/search/DifferentialSearchIndexer.php b/src/applications/differential/search/DifferentialSearchIndexer.php index 33f1d14238..c7365e382c 100644 --- a/src/applications/differential/search/DifferentialSearchIndexer.php +++ b/src/applications/differential/search/DifferentialSearchIndexer.php @@ -23,6 +23,7 @@ final class DifferentialSearchIndexer $aux_fields = DifferentialFieldSelector::newSelector() ->getFieldSpecifications(); foreach ($aux_fields as $key => $aux_field) { + $aux_field->setUser(PhabricatorUser::getOmnipotentUser()); if (!$aux_field->shouldAddToSearchIndex()) { unset($aux_fields[$key]); } @@ -103,6 +104,7 @@ final class DifferentialSearchIndexer $ccphids = $rev->getCCPHIDs(); $handles = id(new PhabricatorObjectHandleData($ccphids)) + ->setViewer(PhabricatorUser::getOmnipotentUser()) ->loadHandles(); foreach ($handles as $phid => $handle) { diff --git a/src/applications/differential/view/DifferentialRevisionListView.php b/src/applications/differential/view/DifferentialRevisionListView.php index aad2cf13f1..a46ac0ffc6 100644 --- a/src/applications/differential/view/DifferentialRevisionListView.php +++ b/src/applications/differential/view/DifferentialRevisionListView.php @@ -55,6 +55,7 @@ final class DifferentialRevisionListView extends AphrontView { } $this->flags = id(new PhabricatorFlagQuery()) + ->setViewer($user) ->withOwnerPHIDs(array($user->getPHID())) ->withObjectPHIDs(mpull($this->revisions, 'getPHID')) ->execute(); @@ -184,10 +185,11 @@ final class DifferentialRevisionListView extends AphrontView { return $table->render(); } - public static function getDefaultFields() { + public static function getDefaultFields(PhabricatorUser $user) { $selector = DifferentialFieldSelector::newSelector(); $fields = $selector->getFieldSpecifications(); foreach ($fields as $key => $field) { + $field->setUser($user); if (!$field->shouldAppearOnRevisionList()) { unset($fields[$key]); } diff --git a/src/applications/diffusion/controller/DiffusionBrowseController.php b/src/applications/diffusion/controller/DiffusionBrowseController.php index fbc56ffea4..fc57792dde 100644 --- a/src/applications/diffusion/controller/DiffusionBrowseController.php +++ b/src/applications/diffusion/controller/DiffusionBrowseController.php @@ -10,6 +10,7 @@ final class DiffusionBrowseController extends DiffusionController { $is_file = true; } else { $browse_query = DiffusionBrowseQuery::newFromDiffusionRequest($drequest); + $browse_query->setViewer($this->getRequest()->getUser()); $results = $browse_query->loadPaths(); $reason = $browse_query->getReasonForEmptyResultSet(); $is_file = ($reason == DiffusionBrowseQuery::REASON_IS_FILE); diff --git a/src/applications/diffusion/controller/DiffusionController.php b/src/applications/diffusion/controller/DiffusionController.php index 2d42b1b277..4eb056e451 100644 --- a/src/applications/diffusion/controller/DiffusionController.php +++ b/src/applications/diffusion/controller/DiffusionController.php @@ -98,6 +98,8 @@ abstract class DiffusionController extends PhabricatorController { } protected function buildOpenRevisions() { + $user = $this->getRequest()->getUser(); + $drequest = $this->getDiffusionRequest(); $repository = $drequest->getRepository(); $path = $drequest->getPath(); @@ -122,7 +124,7 @@ abstract class DiffusionController extends PhabricatorController { $view = id(new DifferentialRevisionListView()) ->setRevisions($revisions) - ->setFields(DifferentialRevisionListView::getDefaultFields()) + ->setFields(DifferentialRevisionListView::getDefaultFields($user)) ->setUser($this->getRequest()->getUser()) ->loadAssets(); diff --git a/src/applications/diffusion/controller/DiffusionPathCompleteController.php b/src/applications/diffusion/controller/DiffusionPathCompleteController.php index ebacb43a2c..bea6d524f7 100644 --- a/src/applications/diffusion/controller/DiffusionPathCompleteController.php +++ b/src/applications/diffusion/controller/DiffusionPathCompleteController.php @@ -32,6 +32,7 @@ final class DiffusionPathCompleteController extends DiffusionController { )); $browse_query = DiffusionBrowseQuery::newFromDiffusionRequest($drequest); + $browse_query->setViewer($request->getUser()); $paths = $browse_query->loadPaths(); $output = array(); diff --git a/src/applications/diffusion/controller/DiffusionPathValidateController.php b/src/applications/diffusion/controller/DiffusionPathValidateController.php index 80a6658b99..04406f3d94 100644 --- a/src/applications/diffusion/controller/DiffusionPathValidateController.php +++ b/src/applications/diffusion/controller/DiffusionPathValidateController.php @@ -27,6 +27,7 @@ final class DiffusionPathValidateController extends DiffusionController { )); $browse_query = DiffusionBrowseQuery::newFromDiffusionRequest($drequest); + $browse_query->setUser($request->getUser()); $browse_query->needValidityOnly(true); $valid = $browse_query->loadPaths(); diff --git a/src/applications/diffusion/controller/DiffusionRepositoryController.php b/src/applications/diffusion/controller/DiffusionRepositoryController.php index 86b12aa8c9..31ced045c0 100644 --- a/src/applications/diffusion/controller/DiffusionRepositoryController.php +++ b/src/applications/diffusion/controller/DiffusionRepositoryController.php @@ -19,6 +19,7 @@ final class DiffusionRepositoryController extends DiffusionController { $history = $history_query->loadHistory(); $browse_query = DiffusionBrowseQuery::newFromDiffusionRequest($drequest); + $browse_query->setUser($this->getRequest()->getUser()); $browse_results = $browse_query->loadPaths(); $phids = array(); diff --git a/src/applications/diffusion/query/browse/DiffusionBrowseQuery.php b/src/applications/diffusion/query/browse/DiffusionBrowseQuery.php index 6a439ab2c4..1f97a339df 100644 --- a/src/applications/diffusion/query/browse/DiffusionBrowseQuery.php +++ b/src/applications/diffusion/query/browse/DiffusionBrowseQuery.php @@ -8,6 +8,16 @@ abstract class DiffusionBrowseQuery { protected $existedAtCommit; protected $deletedAtCommit; protected $validityOnly; + private $viewer; + + public function setViewer(PhabricatorUser $viewer) { + $this->viewer = $viewer; + return $this; + } + + public function getViewer() { + return $this->viewer; + } const REASON_IS_FILE = 'is-file'; const REASON_IS_DELETED = 'is-deleted'; @@ -107,6 +117,7 @@ abstract class DiffusionBrowseQuery { $content_query = DiffusionFileContentQuery::newFromDiffusionRequest( $readme_request); + $content_query->setViewer($this->getViewer()); $content_query->loadFileContent(); $readme_content = $content_query->getRawData(); diff --git a/src/applications/diffusion/query/filecontent/DiffusionFileContentQuery.php b/src/applications/diffusion/query/filecontent/DiffusionFileContentQuery.php index a821dfa32a..086ff4f458 100644 --- a/src/applications/diffusion/query/filecontent/DiffusionFileContentQuery.php +++ b/src/applications/diffusion/query/filecontent/DiffusionFileContentQuery.php @@ -85,9 +85,7 @@ abstract class DiffusionFileContentQuery extends DiffusionQuery { } $loader = new PhabricatorObjectHandleData(array_unique($phids)); - if ($this->viewer) { - $loader->setViewer($this->viewer); - } + $loader->setViewer($this->viewer); $handles = $loader->loadHandles(); foreach ($commits_data as $data) { diff --git a/src/applications/directory/controller/PhabricatorDirectoryMainController.php b/src/applications/directory/controller/PhabricatorDirectoryMainController.php index fa4ee538bb..15a4f24e41 100644 --- a/src/applications/directory/controller/PhabricatorDirectoryMainController.php +++ b/src/applications/directory/controller/PhabricatorDirectoryMainController.php @@ -210,7 +210,7 @@ final class PhabricatorDirectoryMainController $revision_view = id(new DifferentialRevisionListView()) ->setHighlightAge(true) ->setRevisions(array_merge($blocking, $active)) - ->setFields(DifferentialRevisionListView::getDefaultFields()) + ->setFields(DifferentialRevisionListView::getDefaultFields($user)) ->setUser($user) ->loadAssets(); $phids = array_merge( diff --git a/src/applications/flag/application/PhabricatorApplicationFlags.php b/src/applications/flag/application/PhabricatorApplicationFlags.php index b37329c3de..76af32f47a 100644 --- a/src/applications/flag/application/PhabricatorApplicationFlags.php +++ b/src/applications/flag/application/PhabricatorApplicationFlags.php @@ -28,6 +28,7 @@ final class PhabricatorApplicationFlags extends PhabricatorApplication { $status = array(); $flags = id(new PhabricatorFlagQuery()) + ->setViewer($user) ->withOwnerPHIDs(array($user->getPHID())) ->execute(); diff --git a/src/applications/flag/conduit/ConduitAPI_flag_Method.php b/src/applications/flag/conduit/ConduitAPI_flag_Method.php index 7445640403..52aed8f459 100644 --- a/src/applications/flag/conduit/ConduitAPI_flag_Method.php +++ b/src/applications/flag/conduit/ConduitAPI_flag_Method.php @@ -5,9 +5,11 @@ */ abstract class ConduitAPI_flag_Method extends ConduitAPIMethod { - protected function attachHandleToFlag($flag) { + protected function attachHandleToFlag($flag, PhabricatorUser $user) { $flag->attachHandle( - PhabricatorObjectHandleData::loadOneHandle($flag->getObjectPHID())); + PhabricatorObjectHandleData::loadOneHandle( + $flag->getObjectPHID(), + $user)); } protected function buildFlagInfoDictionary($flag) { diff --git a/src/applications/flag/conduit/ConduitAPI_flag_delete_Method.php b/src/applications/flag/conduit/ConduitAPI_flag_delete_Method.php index b434c57b79..396dea5f82 100644 --- a/src/applications/flag/conduit/ConduitAPI_flag_delete_Method.php +++ b/src/applications/flag/conduit/ConduitAPI_flag_delete_Method.php @@ -50,7 +50,7 @@ final class ConduitAPI_flag_delete_Method extends ConduitAPI_flag_Method { } else { throw new ConduitException('ERR_NEED_PARAM'); } - $this->attachHandleToFlag($flag); + $this->attachHandleToFlag($flag, $request->getUser()); $ret = $this->buildFlagInfoDictionary($flag); $flag->delete(); return $ret; diff --git a/src/applications/flag/conduit/ConduitAPI_flag_edit_Method.php b/src/applications/flag/conduit/ConduitAPI_flag_edit_Method.php index 98e665d057..cb4a98cb98 100644 --- a/src/applications/flag/conduit/ConduitAPI_flag_edit_Method.php +++ b/src/applications/flag/conduit/ConduitAPI_flag_edit_Method.php @@ -54,7 +54,7 @@ final class ConduitAPI_flag_edit_Method extends ConduitAPI_flag_Method { ->setNote($request->getValue('note', '')); $new = true; } - $this->attachHandleToFlag($flag); + $this->attachHandleToFlag($flag, $request->getUser()); $flag->save(); $ret = $this->buildFlagInfoDictionary($flag); $ret['new'] = $new; diff --git a/src/applications/flag/query/PhabricatorFlagQuery.php b/src/applications/flag/query/PhabricatorFlagQuery.php index 004c065604..8ee7b33753 100644 --- a/src/applications/flag/query/PhabricatorFlagQuery.php +++ b/src/applications/flag/query/PhabricatorFlagQuery.php @@ -84,9 +84,7 @@ final class PhabricatorFlagQuery { if ($this->needHandles || $this->needObjects) { $phids = ipull($data, 'objectPHID'); $query = new PhabricatorObjectHandleData($phids); - if ($this->viewer) { - $query->setViewer($this->viewer); - } + $query->setViewer($this->viewer); if ($this->needHandles) { $handles = $query->loadHandles(); diff --git a/src/applications/herald/adapter/HeraldObjectAdapter.php b/src/applications/herald/adapter/HeraldObjectAdapter.php index 87c6b22f2f..0a1d2c7b43 100644 --- a/src/applications/herald/adapter/HeraldObjectAdapter.php +++ b/src/applications/herald/adapter/HeraldObjectAdapter.php @@ -25,7 +25,9 @@ abstract class HeraldObjectAdapter { 'Object already flagged.'); } - $handle = PhabricatorObjectHandleData::loadOneHandle($phid); + $handle = PhabricatorObjectHandleData::loadOneHandle( + $phid, + $user); $flag = new PhabricatorFlag(); $flag->setOwnerPHID($user->getPHID()); diff --git a/src/applications/herald/controller/HeraldHomeController.php b/src/applications/herald/controller/HeraldHomeController.php index c058881e31..66d95c3956 100644 --- a/src/applications/herald/controller/HeraldHomeController.php +++ b/src/applications/herald/controller/HeraldHomeController.php @@ -126,8 +126,11 @@ final class HeraldHomeController extends HeraldController { } private function renderAuthorFilter($phid) { + $user = $this->getRequest()->getUser(); if ($phid) { - $handle = PhabricatorObjectHandleData::loadOneHandle($phid); + $handle = PhabricatorObjectHandleData::loadOneHandle( + $phid, + $user); $tokens = array( $phid => $handle->getFullName(), ); @@ -136,7 +139,7 @@ final class HeraldHomeController extends HeraldController { } $form = id(new AphrontFormView()) - ->setUser($this->getRequest()->getUser()) + ->setUser($user) ->appendChild( id(new AphrontFormTokenizerControl()) ->setName('set_phid') diff --git a/src/applications/herald/storage/HeraldRule.php b/src/applications/herald/storage/HeraldRule.php index 1d0d979547..30436849e4 100644 --- a/src/applications/herald/storage/HeraldRule.php +++ b/src/applications/herald/storage/HeraldRule.php @@ -76,6 +76,7 @@ final class HeraldRule extends HeraldDAO { } $handles = id(new PhabricatorObjectHandleData(array_keys($users))) + ->setViewer(PhabricatorUser::getOmnipotentUser()) ->loadHandles(); foreach ($rules as $key => $rule) { diff --git a/src/applications/maniphest/ManiphestTaskQuery.php b/src/applications/maniphest/ManiphestTaskQuery.php index 696dcf34bf..7e54ba3244 100644 --- a/src/applications/maniphest/ManiphestTaskQuery.php +++ b/src/applications/maniphest/ManiphestTaskQuery.php @@ -611,7 +611,11 @@ final class ManiphestTaskQuery extends PhabricatorQuery { } } + // 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(); $max = 1; diff --git a/src/applications/maniphest/controller/ManiphestExportController.php b/src/applications/maniphest/controller/ManiphestExportController.php index a33809b745..d3a22a9a42 100644 --- a/src/applications/maniphest/controller/ManiphestExportController.php +++ b/src/applications/maniphest/controller/ManiphestExportController.php @@ -73,7 +73,9 @@ final class ManiphestExportController extends ManiphestController { $query->setParameter('order', 'p'); $query->setParameter('group', 'n'); - list($tasks, $handles) = ManiphestTaskListController::loadTasks($query); + list($tasks, $handles) = ManiphestTaskListController::loadTasks( + $query, + $user); // Ungroup tasks. $tasks = array_mergev($tasks); diff --git a/src/applications/maniphest/controller/ManiphestTaskListController.php b/src/applications/maniphest/controller/ManiphestTaskListController.php index e90d0379c3..1d8532bb22 100644 --- a/src/applications/maniphest/controller/ManiphestTaskListController.php +++ b/src/applications/maniphest/controller/ManiphestTaskListController.php @@ -89,7 +89,9 @@ final class ManiphestTaskListController extends ManiphestController { // Execute the query. - list($tasks, $handles, $total_count) = self::loadTasks($query); + list($tasks, $handles, $total_count) = self::loadTasks( + $query, + $user); // Extract information we need to render the filters from the query. @@ -416,7 +418,10 @@ final class ManiphestTaskListController extends ManiphestController { )); } - public static function loadTasks(PhabricatorSearchQuery $search_query) { + public static function loadTasks( + PhabricatorSearchQuery $search_query, + PhabricatorUser $viewer) { + $any_project = false; $search_text = $search_query->getParameter('fullTextSearch'); $user_phids = $search_query->getParameter('userPHIDs', array()); @@ -552,6 +557,7 @@ final class ManiphestTaskListController extends ManiphestController { $any_project_phids, array_mergev(mpull($data, 'getProjectPHIDs'))); $handles = id(new PhabricatorObjectHandleData($handle_phids)) + ->setViewer($viewer) ->loadHandles(); switch ($search_query->getParameter('group')) { diff --git a/src/applications/maniphest/editor/ManiphestTransactionEditor.php b/src/applications/maniphest/editor/ManiphestTransactionEditor.php index 427a635b6b..a31d5eba34 100644 --- a/src/applications/maniphest/editor/ManiphestTransactionEditor.php +++ b/src/applications/maniphest/editor/ManiphestTransactionEditor.php @@ -130,6 +130,7 @@ final class ManiphestTransactionEditor extends PhabricatorEditor { case ManiphestTransactionType::TYPE_OWNER: if ($new) { $handles = id(new PhabricatorObjectHandleData(array($new))) + ->setViewer($this->getActor()) ->loadHandles(); $task->setOwnerOrdering($handles[$new]->getName()); } else { diff --git a/src/applications/maniphest/search/ManiphestSearchIndexer.php b/src/applications/maniphest/search/ManiphestSearchIndexer.php index 93a5ff88f3..f2013a4ce6 100644 --- a/src/applications/maniphest/search/ManiphestSearchIndexer.php +++ b/src/applications/maniphest/search/ManiphestSearchIndexer.php @@ -111,6 +111,7 @@ 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))) + ->setViewer(PhabricatorUser::getOmnipotentUser()) ->loadHandles(); foreach ($ccs as $cc => $time) { $doc->addRelationship( diff --git a/src/applications/metamta/PhabricatorMail.php b/src/applications/metamta/PhabricatorMail.php new file mode 100644 index 0000000000..c0ef8c559b --- /dev/null +++ b/src/applications/metamta/PhabricatorMail.php @@ -0,0 +1,16 @@ +actor = $actor; + return $this; + } + + public function getActor() { + return $this->actor; + } + +} diff --git a/src/applications/metamta/replyhandler/PhabricatorMailReplyHandler.php b/src/applications/metamta/replyhandler/PhabricatorMailReplyHandler.php index b251b8bdd1..7970aeb571 100644 --- a/src/applications/metamta/replyhandler/PhabricatorMailReplyHandler.php +++ b/src/applications/metamta/replyhandler/PhabricatorMailReplyHandler.php @@ -88,7 +88,10 @@ abstract class PhabricatorMailReplyHandler { $template->setRelatedPHID($mail->getRelatedPHID()); $phid = $this->getActor()->getPHID(); $tos = array( - $phid => PhabricatorObjectHandleData::loadOneHandle($phid) + $phid => PhabricatorObjectHandleData::loadOneHandle( + $phid, + // TODO: This could be cleaner (T603). + PhabricatorUser::getOmnipotentUser()), ); $mails = $this->multiplexMail($template, $tos, array()); diff --git a/src/applications/owners/mail/PackageMail.php b/src/applications/owners/mail/PackageMail.php index 5d4b45203f..9750b0f954 100644 --- a/src/applications/owners/mail/PackageMail.php +++ b/src/applications/owners/mail/PackageMail.php @@ -1,6 +1,6 @@ mailTo, array($package->getActorPHID()), array_keys($this->paths)); - $this->handles = id(new PhabricatorObjectHandleData($phids))->loadHandles(); + $this->handles = id(new PhabricatorObjectHandleData($phids)) + ->setViewer($this->getActor()) + ->loadHandles(); } final protected function renderSummarySection() { diff --git a/src/applications/owners/mail/PackageModifyMail.php b/src/applications/owners/mail/PackageModifyMail.php index e7e6046ea2..4ddafce784 100644 --- a/src/applications/owners/mail/PackageModifyMail.php +++ b/src/applications/owners/mail/PackageModifyMail.php @@ -59,7 +59,9 @@ final class PackageModifyMail extends PackageMail { array( $this->getPackage()->getActorPHID(), )); - $this->handles = id(new PhabricatorObjectHandleData($phids))->loadHandles(); + $this->handles = id(new PhabricatorObjectHandleData($phids)) + ->setViewer($this->getActor()) + ->loadHandles(); } protected function renderDescriptionSection() { diff --git a/src/applications/owners/storage/PhabricatorOwnersPackage.php b/src/applications/owners/storage/PhabricatorOwnersPackage.php index 24b21b68f8..25a4f4c611 100644 --- a/src/applications/owners/storage/PhabricatorOwnersPackage.php +++ b/src/applications/owners/storage/PhabricatorOwnersPackage.php @@ -214,6 +214,12 @@ final class PhabricatorOwnersPackage extends PhabricatorOwnersDAO return $ids; } + private function getActor() { + // TODO: This should be cleaner, but we'd likely need to move the whole + // thing to an Editor (T603). + return PhabricatorUser::getOmnipotentUser(); + } + public function save() { if ($this->getID()) { @@ -294,6 +300,7 @@ final class PhabricatorOwnersPackage extends PhabricatorOwnersDAO 'path' => $path, )); $query = DiffusionBrowseQuery::newFromDiffusionRequest($drequest); + $query->setViewer($this->getActor()); $query->needValidityOnly(true); $valid = $query->loadPaths(); $is_directory = true; @@ -344,13 +351,16 @@ final class PhabricatorOwnersPackage extends PhabricatorOwnersDAO $add_paths, $remove_paths); } + $mail->setActor($this->getActor()); $mail->send(); return $ret; } public function delete() { - $mails = id(new PackageDeleteMail($this))->prepareMails(); + $mails = id(new PackageDeleteMail($this)) + ->setActor($this->getActor()) + ->prepareMails(); $this->openTransaction(); foreach ($this->loadOwners() as $owner) { diff --git a/src/applications/phame/skins/PhameBasicBlogSkin.php b/src/applications/phame/skins/PhameBasicBlogSkin.php index 2c6f91e97b..2040e98a33 100644 --- a/src/applications/phame/skins/PhameBasicBlogSkin.php +++ b/src/applications/phame/skins/PhameBasicBlogSkin.php @@ -295,6 +295,7 @@ abstract class PhameBasicBlogSkin extends PhameBlogSkin { } $handles = id(new PhabricatorObjectHandleData($phids)) + ->setViewer($user) ->loadHandles(); $engine->process(); diff --git a/src/applications/phame/storage/PhameBlog.php b/src/applications/phame/storage/PhameBlog.php index 6f8c5f34b3..19f77c639f 100644 --- a/src/applications/phame/storage/PhameBlog.php +++ b/src/applications/phame/storage/PhameBlog.php @@ -131,6 +131,8 @@ final class PhameBlog extends PhameDAO } $bloggers = id(new PhabricatorObjectHandleData($blogger_phids)) + // TODO: This should be Query-based (T603). + ->setViewer(PhabricatorUser::getOmnipotentUser()) ->loadHandles(); $this->attachBloggers($bloggers); diff --git a/src/applications/phid/conduit/ConduitAPI_phid_info_Method.php b/src/applications/phid/conduit/ConduitAPI_phid_info_Method.php index 0cc657ef5e..d853274f9a 100644 --- a/src/applications/phid/conduit/ConduitAPI_phid_info_Method.php +++ b/src/applications/phid/conduit/ConduitAPI_phid_info_Method.php @@ -39,6 +39,7 @@ final class ConduitAPI_phid_info_Method $phid = $request->getValue('phid'); $handles = id(new PhabricatorObjectHandleData(array($phid))) + ->setViewer($request->getUser()) ->loadHandles(); $handle = $handles[$phid]; diff --git a/src/applications/phid/conduit/ConduitAPI_phid_lookup_Method.php b/src/applications/phid/conduit/ConduitAPI_phid_lookup_Method.php index 0b60352733..d69987afd8 100644 --- a/src/applications/phid/conduit/ConduitAPI_phid_lookup_Method.php +++ b/src/applications/phid/conduit/ConduitAPI_phid_lookup_Method.php @@ -35,7 +35,9 @@ final class ConduitAPI_phid_lookup_Method } $handles = id(new PhabricatorObjectHandleData($phids)) + ->setViewer($request->getUser()) ->loadHandles(); + $result = array(); foreach ($phids as $name => $phid) { if (isset($handles[$phid]) && $handles[$phid]->isComplete()) { diff --git a/src/applications/phid/conduit/ConduitAPI_phid_query_Method.php b/src/applications/phid/conduit/ConduitAPI_phid_query_Method.php index f19feddbf1..e433aae2b5 100644 --- a/src/applications/phid/conduit/ConduitAPI_phid_query_Method.php +++ b/src/applications/phid/conduit/ConduitAPI_phid_query_Method.php @@ -29,6 +29,7 @@ final class ConduitAPI_phid_query_Method $phids = $request->getValue('phids'); $handles = id(new PhabricatorObjectHandleData($phids)) + ->setViewer($request->getUser()) ->loadHandles(); $result = array(); diff --git a/src/applications/phid/handle/PhabricatorObjectHandleData.php b/src/applications/phid/handle/PhabricatorObjectHandleData.php index 94f6a02ad3..88b2d522ad 100644 --- a/src/applications/phid/handle/PhabricatorObjectHandleData.php +++ b/src/applications/phid/handle/PhabricatorObjectHandleData.php @@ -14,13 +14,9 @@ final class PhabricatorObjectHandleData { return $this; } - public static function loadOneHandle($phid, $viewer = null) { + public static function loadOneHandle($phid, PhabricatorUser $viewer) { $query = new PhabricatorObjectHandleData(array($phid)); - - if ($viewer) { - $query->setViewer($viewer); - } - + $query->setViewer($viewer); $handles = $query->loadHandles(); return $handles[$phid]; } @@ -37,6 +33,11 @@ final class PhabricatorObjectHandleData { } private function loadObjectsOfType($type, array $phids) { + if (!$this->viewer) { + throw new Exception( + "You must provide a viewer to load handles or objects."); + } + switch ($type) { case PhabricatorPHIDConstants::PHID_TYPE_USER: @@ -73,15 +74,10 @@ final class PhabricatorObjectHandleData { return mpull($files, null, 'getPHID'); case PhabricatorPHIDConstants::PHID_TYPE_PROJ: - $object = new PhabricatorProject(); - if ($this->viewer) { - $projects = id(new PhabricatorProjectQuery()) - ->setViewer($this->viewer) - ->withPHIDs($phids) - ->execute(); - } else { - $projects = $object->loadAllWhere('phid IN (%Ls)', $phids); - } + $projects = id(new PhabricatorProjectQuery()) + ->setViewer($this->viewer) + ->withPHIDs($phids) + ->execute(); return mpull($projects, null, 'getPHID'); case PhabricatorPHIDConstants::PHID_TYPE_REPO: @@ -260,10 +256,8 @@ final class PhabricatorObjectHandleData { $handle->setComplete(true); if (isset($statuses[$phid])) { $handle->setStatus($statuses[$phid]->getTextStatus()); - if ($this->viewer) { - $handle->setTitle( - $statuses[$phid]->getTerseSummary($this->viewer)); - } + $handle->setTitle( + $statuses[$phid]->getTerseSummary($this->viewer)); } $handle->setDisabled($user->getIsDisabled()); diff --git a/src/applications/pholio/controller/PholioInlineController.php b/src/applications/pholio/controller/PholioInlineController.php index 2f2772186f..2a17af1bb7 100644 --- a/src/applications/pholio/controller/PholioInlineController.php +++ b/src/applications/pholio/controller/PholioInlineController.php @@ -22,8 +22,7 @@ final class PholioInlineController extends PholioController { $user->getPHID()); $author_phids = mpull($inline_comments, 'getAuthorPHID'); - $authors = id(new PhabricatorObjectHandleData($author_phids)) - ->loadHandles(); + $authors = $this->loadViewerHandles($author_phids); $inlines = array(); diff --git a/src/applications/pholio/controller/PholioInlineSaveController.php b/src/applications/pholio/controller/PholioInlineSaveController.php index ac83e09113..087cbbbaa3 100644 --- a/src/applications/pholio/controller/PholioInlineSaveController.php +++ b/src/applications/pholio/controller/PholioInlineSaveController.php @@ -63,7 +63,9 @@ final class PholioInlineSaveController extends PholioController { ->setInlineComment($draft) ->setEditable(true) ->setHandle( - PhabricatorObjectHandleData::loadOneHandle($user->getPHID())); + PhabricatorObjectHandleData::loadOneHandle( + $user->getPHID(), + $user)); return id(new AphrontAjaxResponse()) ->setContent( diff --git a/src/applications/pholio/controller/PholioInlineViewController.php b/src/applications/pholio/controller/PholioInlineViewController.php index 898b352d32..886e61f57a 100644 --- a/src/applications/pholio/controller/PholioInlineViewController.php +++ b/src/applications/pholio/controller/PholioInlineViewController.php @@ -17,7 +17,8 @@ final class PholioInlineViewController extends PholioController { $inline_comment = id(new PholioTransactionComment())->load($this->id); $handle = PhabricatorObjectHandleData::loadOneHandle( - $inline_comment->getAuthorPHID()); + $inline_comment->getAuthorPHID(), + $user); $inline_view = id(new PholioInlineCommentView()) ->setHandle($handle) diff --git a/src/applications/ponder/mail/PonderAnsweredMail.php b/src/applications/ponder/mail/PonderAnsweredMail.php index a0b8a11f80..2e1b5adde4 100644 --- a/src/applications/ponder/mail/PonderAnsweredMail.php +++ b/src/applications/ponder/mail/PonderAnsweredMail.php @@ -10,6 +10,7 @@ final class PonderAnsweredMail extends PonderMail { $this->setQuestion($question); $this->setTarget($target); $this->setActorHandle($actor); + $this->setActor($actor); } protected function renderVaryPrefix() { diff --git a/src/applications/ponder/mail/PonderCommentMail.php b/src/applications/ponder/mail/PonderCommentMail.php index 57b55ececf..3399b1fd1a 100644 --- a/src/applications/ponder/mail/PonderCommentMail.php +++ b/src/applications/ponder/mail/PonderCommentMail.php @@ -10,6 +10,7 @@ final class PonderCommentMail extends PonderMail { $this->setQuestion($question); $this->setTarget($target); $this->setActorHandle($actor); + $this->setActor($actor); } protected function renderVaryPrefix() { diff --git a/src/applications/ponder/mail/PonderMail.php b/src/applications/ponder/mail/PonderMail.php index 2b79f57f0a..e15016e508 100644 --- a/src/applications/ponder/mail/PonderMail.php +++ b/src/applications/ponder/mail/PonderMail.php @@ -1,6 +1,6 @@ getThreadID(); $handles = id(new PhabricatorObjectHandleData($email_to)) + ->setViewer($this->getActor()) ->loadHandles(); $reply_handler = new PonderReplyHandler(); diff --git a/src/applications/ponder/mail/PonderMentionMail.php b/src/applications/ponder/mail/PonderMentionMail.php index 63cc659f99..3178c9f703 100644 --- a/src/applications/ponder/mail/PonderMentionMail.php +++ b/src/applications/ponder/mail/PonderMentionMail.php @@ -10,6 +10,7 @@ final class PonderMentionMail extends PonderMail { $this->setQuestion($question); $this->setTarget($target); $this->setActorHandle($actor); + $this->setActor($actor); } protected function renderVaryPrefix() { diff --git a/src/applications/ponder/search/PonderSearchIndexer.php b/src/applications/ponder/search/PonderSearchIndexer.php index 856f74ba84..8b2a00f909 100644 --- a/src/applications/ponder/search/PonderSearchIndexer.php +++ b/src/applications/ponder/search/PonderSearchIndexer.php @@ -55,6 +55,7 @@ final class PonderSearchIndexer $subscribers = PhabricatorSubscribersQuery::loadSubscribersForPHID( $question->getPHID()); $handles = id(new PhabricatorObjectHandleData($subscribers)) + ->setViewer(PhabricatorUser::getOmnipotentUser()) ->loadHandles(); foreach ($handles as $phid => $handle) { diff --git a/src/applications/repository/worker/PhabricatorRepositoryCommitHeraldWorker.php b/src/applications/repository/worker/PhabricatorRepositoryCommitHeraldWorker.php index dfbf3a746e..5baa23443d 100644 --- a/src/applications/repository/worker/PhabricatorRepositoryCommitHeraldWorker.php +++ b/src/applications/repository/worker/PhabricatorRepositoryCommitHeraldWorker.php @@ -157,7 +157,9 @@ final class PhabricatorRepositoryCommitHeraldWorker $mails = $reply_handler->multiplexMail( $template, - id(new PhabricatorObjectHandleData($email_phids))->loadHandles(), + id(new PhabricatorObjectHandleData($email_phids)) + ->setViewer(PhabricatorUser::getOmnipotentUser()) + ->loadHandles(), array()); foreach ($mails as $mail) { diff --git a/src/applications/repository/worker/commitmessageparser/PhabricatorRepositoryCommitMessageParserWorker.php b/src/applications/repository/worker/commitmessageparser/PhabricatorRepositoryCommitMessageParserWorker.php index d457ec22f0..0223179e5a 100644 --- a/src/applications/repository/worker/commitmessageparser/PhabricatorRepositoryCommitMessageParserWorker.php +++ b/src/applications/repository/worker/commitmessageparser/PhabricatorRepositoryCommitMessageParserWorker.php @@ -168,11 +168,13 @@ abstract class PhabricatorRepositoryCommitMessageParserWorker $committer_name = $this->loadUserName( $committer_phid, - $data->getCommitDetail('committer')); + $data->getCommitDetail('committer'), + $actor); $author_name = $this->loadUserName( $author_phid, - $data->getAuthorName()); + $data->getAuthorName(), + $actor); $info = array(); $info[] = "authored by {$author_name}"; @@ -211,11 +213,13 @@ abstract class PhabricatorRepositoryCommitMessageParserWorker $data->save(); } - private function loadUserName($user_phid, $default) { + private function loadUserName($user_phid, $default, PhabricatorUser $actor) { if (!$user_phid) { return $default; } - $handle = PhabricatorObjectHandleData::loadOneHandle($user_phid); + $handle = PhabricatorObjectHandleData::loadOneHandle( + $user_phid, + $actor); return '@'.$handle->getName(); } @@ -332,6 +336,7 @@ abstract class PhabricatorRepositoryCommitMessageParserWorker 'path' => $path, )); $corpus = DiffusionFileContentQuery::newFromDiffusionRequest($drequest) + ->setViewer(PhabricatorUser::getOmnipotentUser()) ->loadFileContent() ->getCorpus(); if ($files[$file_phid]->loadFileData() != $corpus) { diff --git a/src/applications/search/controller/PhabricatorSearchAttachController.php b/src/applications/search/controller/PhabricatorSearchAttachController.php index 75b126eee2..a5070368d4 100644 --- a/src/applications/search/controller/PhabricatorSearchAttachController.php +++ b/src/applications/search/controller/PhabricatorSearchAttachController.php @@ -27,6 +27,7 @@ final class PhabricatorSearchAttachController $user = $request->getUser(); $handle_data = new PhabricatorObjectHandleData(array($this->phid)); + $handle_data->setViewer($user); $handles = $handle_data->loadHandles(); $handle = $handles[$this->phid]; diff --git a/src/applications/search/engine/PhabricatorSearchEngineElastic.php b/src/applications/search/engine/PhabricatorSearchEngineElastic.php index aa5273312d..e7f0b693bc 100644 --- a/src/applications/search/engine/PhabricatorSearchEngineElastic.php +++ b/src/applications/search/engine/PhabricatorSearchEngineElastic.php @@ -25,7 +25,9 @@ final class PhabricatorSearchEngineElastic extends PhabricatorSearchEngine { $type = $doc->getDocumentType(); $phid = $doc->getPHID(); - $handle = PhabricatorObjectHandleData::loadOneHandle($phid); + $handle = PhabricatorObjectHandleData::loadOneHandle( + $phid, + PhabricatorUser::getOmnipotentUser()); // URL is not used internally but it can be useful externally. $spec = array( diff --git a/src/applications/slowvote/controller/PhabricatorSlowvotePollController.php b/src/applications/slowvote/controller/PhabricatorSlowvotePollController.php index 8a519a1e97..5d9aa40bcc 100644 --- a/src/applications/slowvote/controller/PhabricatorSlowvotePollController.php +++ b/src/applications/slowvote/controller/PhabricatorSlowvotePollController.php @@ -98,6 +98,7 @@ final class PhabricatorSlowvotePollController )); $query = new PhabricatorObjectHandleData($phids); + $query->setViewer($user); $handles = $query->loadHandles(); $objects = $query->loadObjects(); diff --git a/src/applications/tokens/event/PhabricatorTokenUIEventListener.php b/src/applications/tokens/event/PhabricatorTokenUIEventListener.php index 71a4df5b27..a046c4cd5e 100644 --- a/src/applications/tokens/event/PhabricatorTokenUIEventListener.php +++ b/src/applications/tokens/event/PhabricatorTokenUIEventListener.php @@ -93,6 +93,7 @@ final class PhabricatorTokenUIEventListener $author_phids = mpull($tokens_given, 'getAuthorPHID'); $handles = id(new PhabricatorObjectHandleData($author_phids)) + ->setViewer($user) ->loadHandles(); $list = array(); diff --git a/src/applications/xhprof/view/PhabricatorXHProfSampleListView.php b/src/applications/xhprof/view/PhabricatorXHProfSampleListView.php index 7bc8117519..c10f8eb3d7 100644 --- a/src/applications/xhprof/view/PhabricatorXHProfSampleListView.php +++ b/src/applications/xhprof/view/PhabricatorXHProfSampleListView.php @@ -23,7 +23,9 @@ final class PhabricatorXHProfSampleListView extends AphrontView { } $user_phids = mpull($this->samples, 'getUserPHID'); - $users = id(new PhabricatorObjectHandleData($user_phids))->loadObjects(); + $users = id(new PhabricatorObjectHandleData($user_phids)) + ->setViewer($this->getUser()) + ->loadObjects(); foreach ($this->samples as $sample) { $sample_link = phutil_tag( 'a', diff --git a/src/infrastructure/edges/query/PhabricatorEdgeQuery.php b/src/infrastructure/edges/query/PhabricatorEdgeQuery.php index 53f450a456..160aff9b0b 100644 --- a/src/infrastructure/edges/query/PhabricatorEdgeQuery.php +++ b/src/infrastructure/edges/query/PhabricatorEdgeQuery.php @@ -213,6 +213,7 @@ final class PhabricatorEdgeQuery extends PhabricatorQuery { * write code like this: * * $query = new PhabricatorEdgeQuery(); + * $query->setViewer($viewer); * $query->withSourcePHIDs(mpull($objects, 'getPHID')); * $query->withEdgeTypes(array($some_type)); * $query->execute(); @@ -220,6 +221,7 @@ final class PhabricatorEdgeQuery extends PhabricatorQuery { * // Gets all of the destinations. * $all_phids = $query->getDestinationPHIDs(); * $handles = id(new PhabricatorObjectHandleData($all_phids)) + * ->setViewer($viewer) * ->loadHandles(); * * foreach ($objects as $object) { diff --git a/src/infrastructure/markup/rule/PhabricatorRemarkupRuleObject.php b/src/infrastructure/markup/rule/PhabricatorRemarkupRuleObject.php index dcd5235b52..779b81dd66 100644 --- a/src/infrastructure/markup/rule/PhabricatorRemarkupRuleObject.php +++ b/src/infrastructure/markup/rule/PhabricatorRemarkupRuleObject.php @@ -26,6 +26,11 @@ abstract class PhabricatorRemarkupRuleObject $viewer = $this->getEngine()->getConfig('viewer'); if ($viewer) { $query->setViewer($viewer); + } else { + // TODO: This needs to be fixed; all markup engines need to set viewers -- + // but there are a lot of them (T603). + $query->setViewer(PhabricatorUser::getOmnipotentUser()); + phlog("Warning: Loading handles without a viewing user."); } $handles = $query->loadHandles();