Update some inline comment logic to use more modern "Viewer"-oriented calls/variables

Summary:
Ref T13195. Ref T8573. The inline comment controllers currently use outdated `$user = $this->getRequest()->getUser()` calls.

Instead, use `$viewer = $this->getViewer()`.

This is just a small consistency update with no behavioral changes.

Test Plan: Viewed and added inlines in Differential and Diffusion.

Reviewers: amckinley

Reviewed By: amckinley

Maniphest Tasks: T13195, T8573

Differential Revision: https://secure.phabricator.com/D19633
This commit is contained in:
epriestley
2018-09-04 11:26:30 -07:00
parent dc0924deed
commit 650e74933a
3 changed files with 19 additions and 23 deletions

View File

@@ -50,19 +50,17 @@ final class DiffusionInlineCommentController
}
protected function loadCommentForEdit($id) {
$request = $this->getRequest();
$user = $request->getUser();
$viewer = $this->getViewer();
$inline = $this->loadComment($id);
if (!$this->canEditInlineComment($user, $inline)) {
if (!$this->canEditInlineComment($viewer, $inline)) {
throw new Exception(pht('That comment is not editable!'));
}
return $inline;
}
protected function loadCommentForDone($id) {
$request = $this->getRequest();
$viewer = $request->getUser();
$viewer = $this->getViewer();
$inline = $this->loadComment($id);
if (!$inline) {
@@ -86,11 +84,11 @@ final class DiffusionInlineCommentController
}
private function canEditInlineComment(
PhabricatorUser $user,
PhabricatorUser $viewer,
PhabricatorAuditInlineComment $inline) {
// Only the author may edit a comment.
if ($inline->getAuthorPHID() != $user->getPHID()) {
if ($inline->getAuthorPHID() != $viewer->getPHID()) {
return false;
}