Page Menu
Home
Phabricator
Search
Configure Global Search
Log In
Files
F15335261
D21231.diff
No One
Temporary
Actions
View File
Edit File
Delete File
View Transforms
Subscribe
Mute Notifications
Award Token
Flag For Later
Size
7 KB
Referenced Files
None
Subscribers
None
D21231.diff
View Options
diff --git a/src/applications/differential/controller/DifferentialInlineCommentEditController.php b/src/applications/differential/controller/DifferentialInlineCommentEditController.php
--- a/src/applications/differential/controller/DifferentialInlineCommentEditController.php
+++ b/src/applications/differential/controller/DifferentialInlineCommentEditController.php
@@ -3,6 +3,10 @@
final class DifferentialInlineCommentEditController
extends PhabricatorInlineCommentController {
+ protected function newInlineCommentQuery() {
+ return new DifferentialDiffInlineCommentQuery();
+ }
+
private function getRevisionID() {
return $this->getRequest()->getURIData('id');
}
@@ -58,44 +62,10 @@
->setChangesetID($changeset_id);
}
- protected function loadComment($id) {
- return id(new DifferentialInlineCommentQuery())
- ->setViewer($this->getViewer())
- ->withIDs(array($id))
- ->withDeletedDrafts(true)
- ->needHidden(true)
- ->executeOne();
- }
-
- protected function loadCommentByPHID($phid) {
- return id(new DifferentialInlineCommentQuery())
- ->setViewer($this->getViewer())
- ->withPHIDs(array($phid))
- ->withDeletedDrafts(true)
- ->needHidden(true)
- ->executeOne();
- }
-
- protected function loadCommentForEdit($id) {
- $viewer = $this->getViewer();
-
- $inline = $this->loadComment($id);
- if (!$inline) {
- throw new Exception(
- pht('Unable to load inline "%s".', $id));
- }
-
- if (!$this->canEditInlineComment($viewer, $inline)) {
- throw new Exception(pht('That comment is not editable!'));
- }
-
- return $inline;
- }
-
protected function loadCommentForDone($id) {
$viewer = $this->getViewer();
- $inline = $this->loadComment($id);
+ $inline = $this->loadCommentByID($id);
if (!$inline) {
throw new Exception(pht('Unable to load inline "%d".', $id));
}
@@ -144,7 +114,7 @@
return $inline;
}
- private function canEditInlineComment(
+ protected function canEditInlineComment(
PhabricatorUser $viewer,
DifferentialInlineComment $inline) {
diff --git a/src/applications/diffusion/controller/DiffusionInlineCommentController.php b/src/applications/diffusion/controller/DiffusionInlineCommentController.php
--- a/src/applications/diffusion/controller/DiffusionInlineCommentController.php
+++ b/src/applications/diffusion/controller/DiffusionInlineCommentController.php
@@ -3,6 +3,10 @@
final class DiffusionInlineCommentController
extends PhabricatorInlineCommentController {
+ protected function newInlineCommentQuery() {
+ return new DiffusionDiffInlineCommentQuery();
+ }
+
private function getCommitPHID() {
return $this->getRequest()->getURIData('phid');
}
@@ -41,48 +45,10 @@
->setPathID($path_id);
}
- protected function loadComment($id) {
- $viewer = $this->getViewer();
- $inline = id(new DiffusionDiffInlineCommentQuery())
- ->setViewer($viewer)
- ->withIDs(array($id))
- ->executeOne();
-
- if ($inline) {
- $inline = $inline->newInlineCommentObject();
- }
-
- return $inline;
- }
-
- protected function loadCommentByPHID($phid) {
- $viewer = $this->getViewer();
- $inline = id(new DiffusionDiffInlineCommentQuery())
- ->setViewer($viewer)
- ->withPHIDs(array($phid))
- ->executeOne();
-
- if ($inline) {
- $inline = $inline->newInlineCommentObject();
- }
-
- return $inline;
- }
-
- protected function loadCommentForEdit($id) {
- $viewer = $this->getViewer();
-
- $inline = $this->loadComment($id);
- if (!$this->canEditInlineComment($viewer, $inline)) {
- throw new Exception(pht('That comment is not editable!'));
- }
- return $inline;
- }
-
protected function loadCommentForDone($id) {
$viewer = $this->getViewer();
- $inline = $this->loadComment($id);
+ $inline = $this->loadCommentByID($id);
if (!$inline) {
throw new Exception(pht('Failed to load comment "%d".', $id));
}
@@ -115,7 +81,7 @@
return $inline;
}
- private function canEditInlineComment(
+ protected function canEditInlineComment(
PhabricatorUser $viewer,
PhabricatorAuditInlineComment $inline) {
diff --git a/src/infrastructure/diff/PhabricatorInlineCommentController.php b/src/infrastructure/diff/PhabricatorInlineCommentController.php
--- a/src/infrastructure/diff/PhabricatorInlineCommentController.php
+++ b/src/infrastructure/diff/PhabricatorInlineCommentController.php
@@ -4,10 +4,8 @@
extends PhabricatorController {
abstract protected function createComment();
- abstract protected function loadComment($id);
- abstract protected function loadCommentForEdit($id);
+ abstract protected function newInlineCommentQuery();
abstract protected function loadCommentForDone($id);
- abstract protected function loadCommentByPHID($phid);
abstract protected function loadObjectOwnerPHID(
PhabricatorInlineComment $inline);
abstract protected function deleteComment(
@@ -172,7 +170,7 @@
$is_delete = ($op == 'delete' || $op == 'refdelete');
- $inline = $this->loadCommentForEdit($this->getCommentID());
+ $inline = $this->loadCommentByIDForEdit($this->getCommentID());
if ($is_delete) {
$this->deleteComment($inline);
@@ -182,7 +180,7 @@
return $this->buildEmptyResponse();
case 'edit':
- $inline = $this->loadCommentForEdit($this->getCommentID());
+ $inline = $this->loadCommentByIDForEdit($this->getCommentID());
$text = $this->getCommentText();
if ($request->isFormPost()) {
@@ -228,7 +226,7 @@
return $this->newInlineResponse($inline, $view);
case 'cancel':
- $inline = $this->loadCommentForEdit($this->getCommentID());
+ $inline = $this->loadCommentByIDForEdit($this->getCommentID());
$inline->setIsEditing(false);
@@ -251,7 +249,7 @@
return $this->buildEmptyResponse();
case 'draft':
- $inline = $this->loadCommentForEdit($this->getCommentID());
+ $inline = $this->loadCommentByIDForEdit($this->getCommentID());
$versioned_draft = PhabricatorVersionedDraft::loadOrCreateDraft(
$inline->getPHID(),
@@ -442,5 +440,58 @@
$viewer->getPHID());
}
+ final protected function loadCommentByID($id) {
+ $query = $this->newInlineCommentQuery()
+ ->withIDs(array($id));
+
+ return $this->loadCommentByQuery($query);
+ }
+
+ final protected function loadCommentByPHID($phid) {
+ $query = $this->newInlineCommentQuery()
+ ->withPHIDs(array($phid));
+
+ return $this->loadCommentByQuery($query);
+ }
+
+ final protected function loadCommentByIDForEdit($id) {
+ $viewer = $this->getViewer();
+
+ $query = $this->newInlineCommentQuery()
+ ->withIDs(array($id));
+
+ $inline = $this->loadCommentByQuery($query);
+
+ if (!$inline) {
+ throw new Exception(
+ pht(
+ 'Unable to load inline "%s".',
+ $id));
+ }
+
+ if (!$this->canEditInlineComment($viewer, $inline)) {
+ throw new Exception(
+ pht(
+ 'Inline comment "%s" is not editable.',
+ $id));
+ }
+
+ return $inline;
+ }
+
+ private function loadCommentByQuery(
+ PhabricatorDiffInlineCommentQuery $query) {
+ $viewer = $this->getViewer();
+
+ $inline = $query
+ ->setViewer($viewer)
+ ->executeOne();
+
+ if ($inline) {
+ $inline = $inline->newInlineCommentObject();
+ }
+
+ return $inline;
+ }
}
File Metadata
Details
Attached
Mime Type
text/plain
Expires
Sun, Mar 9, 2:48 PM (2 w, 16 h ago)
Storage Engine
blob
Storage Format
Encrypted (AES-256-CBC)
Storage Handle
7389319
Default Alt Text
D21231.diff (7 KB)
Attached To
Mode
D21231: Lift most "InlineController" querying to the base class
Attached
Detach File
Event Timeline
Log In to Comment