1
0
Fork 0
mirror of https://we.phorge.it/source/phorge.git synced 2024-12-23 14:00:56 +01:00

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

@ -77,19 +77,17 @@ final class DifferentialInlineCommentEditController
}
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) {
@ -128,11 +126,11 @@ final class DifferentialInlineCommentEditController
}
private function canEditInlineComment(
PhabricatorUser $user,
PhabricatorUser $viewer,
DifferentialInlineComment $inline) {
// Only the author may edit a comment.
if ($inline->getAuthorPHID() != $user->getPHID()) {
if ($inline->getAuthorPHID() != $viewer->getPHID()) {
return false;
}

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;
}

View file

@ -88,7 +88,7 @@ abstract class PhabricatorInlineCommentController
public function processRequest() {
$request = $this->getRequest();
$user = $request->getUser();
$viewer = $this->getViewer();
$this->readRequestParameters();
@ -221,7 +221,7 @@ abstract class PhabricatorInlineCommentController
$inline = $this->createComment()
->setChangesetID($this->getChangesetID())
->setAuthorPHID($user->getPHID())
->setAuthorPHID($viewer->getPHID())
->setLineNumber($this->getLineNumber())
->setLineLength($this->getLineLength())
->setIsNewFile($this->getIsNewFile())
@ -313,10 +313,10 @@ abstract class PhabricatorInlineCommentController
private function buildEditDialog() {
$request = $this->getRequest();
$user = $request->getUser();
$viewer = $this->getViewer();
$edit_dialog = id(new PHUIDiffInlineCommentEditView())
->setUser($user)
->setUser($viewer)
->setSubmitURI($request->getRequestURI())
->setIsOnRight($this->getIsOnRight())
->setIsNewFile($this->getIsNewFile())
@ -342,22 +342,22 @@ abstract class PhabricatorInlineCommentController
$on_right) {
$request = $this->getRequest();
$user = $request->getUser();
$viewer = $this->getViewer();
$engine = new PhabricatorMarkupEngine();
$engine->setViewer($user);
$engine->setViewer($viewer);
$engine->addObject(
$inline,
PhabricatorInlineCommentInterface::MARKUP_FIELD_BODY);
$engine->process();
$phids = array($user->getPHID());
$phids = array($viewer->getPHID());
$handles = $this->loadViewerHandles($phids);
$object_owner_phid = $this->loadObjectOwnerPHID($inline);
$view = id(new PHUIDiffInlineCommentDetailView())
->setUser($user)
->setUser($viewer)
->setInlineComment($inline)
->setIsOnRight($on_right)
->setMarkupEngine($engine)
@ -378,7 +378,7 @@ abstract class PhabricatorInlineCommentController
private function renderTextArea($text) {
return id(new PhabricatorRemarkupControl())
->setUser($this->getRequest()->getUser())
->setViewer($this->getViewer())
->setSigil('differential-inline-comment-edit-textarea')
->setName('text')
->setValue($text)