Page MenuHomePhabricator

D19095.id45761.diff
No OneTemporary

D19095.id45761.diff

diff --git a/src/applications/phriction/controller/PhrictionDiffController.php b/src/applications/phriction/controller/PhrictionDiffController.php
--- a/src/applications/phriction/controller/PhrictionDiffController.php
+++ b/src/applications/phriction/controller/PhrictionDiffController.php
@@ -29,10 +29,11 @@
list($l, $r) = explode(',', $ref);
}
- $content = id(new PhrictionContent())->loadAllWhere(
- 'documentID = %d AND version IN (%Ld)',
- $document->getID(),
- array($l, $r));
+ $content = id(new PhrictionContentQuery())
+ ->setViewer($viewer)
+ ->withDocumentPHIDs(array($document->getPHID()))
+ ->withVersions(array($l, $r))
+ ->execute();
$content = mpull($content, null, 'getVersion');
$content_l = idx($content, $l, null);
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
@@ -22,11 +22,6 @@
require_celerity_resource('phriction-document-css');
- $document = id(new PhrictionDocumentQuery())
- ->setViewer($viewer)
- ->withSlugs(array($slug))
- ->executeOne();
-
$version_note = null;
$core_content = '';
$move_notice = '';
@@ -34,6 +29,11 @@
$content = null;
$toc = null;
+ $document = id(new PhrictionDocumentQuery())
+ ->setViewer($viewer)
+ ->withSlugs(array($slug))
+ ->needContent(true)
+ ->executeOne();
if (!$document) {
$document = PhrictionDocument::initializeNewDocument($viewer, $slug);
@@ -69,25 +69,28 @@
$version = $request->getInt('v');
if ($version) {
- $content = id(new PhrictionContent())->loadOneWhere(
- 'documentID = %d AND version = %d',
- $document->getID(),
- $version);
+ $content = id(new PhrictionContentQuery())
+ ->setViewer($viewer)
+ ->withDocumentPHIDs(array($document->getPHID()))
+ ->withVersions(array($version))
+ ->executeOne();
if (!$content) {
return new Aphront404Response();
}
if ($content->getID() != $document->getContentID()) {
- $vdate = phabricator_datetime($content->getDateCreated(), $viewer);
- $version_note = new PHUIInfoView();
- $version_note->setSeverity(PHUIInfoView::SEVERITY_NOTICE);
- $version_note->appendChild(
- pht('You are viewing an older version of this document, as it '.
- 'appeared on %s.', $vdate));
+ $version_note = id(new PHUIInfoView())
+ ->setSeverity(PHUIInfoView::SEVERITY_NOTICE)
+ ->appendChild(
+ pht(
+ 'You are viewing an older version of this document, as it '.
+ 'appeared on %s.',
+ phabricator_datetime($content->getDateCreated(), $viewer)));
}
} else {
- $content = id(new PhrictionContent())->load($document->getContentID());
+ $content = $document->getContent();
}
+
$page_title = $content->getTitle();
$properties = $this
->buildPropertyListView($document, $content, $slug);
diff --git a/src/applications/phriction/controller/PhrictionEditController.php b/src/applications/phriction/controller/PhrictionEditController.php
--- a/src/applications/phriction/controller/PhrictionEditController.php
+++ b/src/applications/phriction/controller/PhrictionEditController.php
@@ -28,10 +28,11 @@
$revert = $request->getInt('revert');
if ($revert) {
- $content = id(new PhrictionContent())->loadOneWhere(
- 'documentID = %d AND version = %d',
- $document->getID(),
- $revert);
+ $content = id(new PhrictionContentQuery())
+ ->setViewer($viewer)
+ ->withDocumentPHIDs(array($document->getPHID()))
+ ->withVersions(array($revert))
+ ->executeOne();
if (!$content) {
return new Aphront404Response();
}
diff --git a/src/applications/phriction/query/PhrictionContentQuery.php b/src/applications/phriction/query/PhrictionContentQuery.php
--- a/src/applications/phriction/query/PhrictionContentQuery.php
+++ b/src/applications/phriction/query/PhrictionContentQuery.php
@@ -6,6 +6,7 @@
private $ids;
private $phids;
private $documentPHIDs;
+ private $versions;
public function withIDs(array $ids) {
$this->ids = $ids;
@@ -22,6 +23,11 @@
return $this;
}
+ public function withVersions(array $versions) {
+ $this->versions = $versions;
+ return $this;
+ }
+
public function newResultObject() {
return new PhrictionContent();
}
@@ -47,6 +53,13 @@
$this->phids);
}
+ if ($this->versions !== null) {
+ $where[] = qsprintf(
+ $conn,
+ 'version IN (%Ld)',
+ $this->versions);
+ }
+
if ($this->documentPHIDs !== null) {
$where[] = qsprintf(
$conn,
diff --git a/src/applications/phriction/query/PhrictionDocumentQuery.php b/src/applications/phriction/query/PhrictionDocumentQuery.php
--- a/src/applications/phriction/query/PhrictionDocumentQuery.php
+++ b/src/applications/phriction/query/PhrictionDocumentQuery.php
@@ -145,9 +145,12 @@
}
if ($this->needContent) {
- $contents = id(new PhrictionContent())->loadAllWhere(
- 'id IN (%Ld)',
- mpull($documents, 'getContentID'));
+ $contents = id(new PhrictionContentQuery())
+ ->setViewer($this->getViewer())
+ ->setParentQuery($this)
+ ->withIDs(mpull($documents, 'getContentID'))
+ ->execute();
+ $contents = mpull($contents, null, 'getID');
foreach ($documents as $key => $document) {
$content_id = $document->getContentID();
diff --git a/src/applications/phriction/storage/PhrictionDocument.php b/src/applications/phriction/storage/PhrictionDocument.php
--- a/src/applications/phriction/storage/PhrictionDocument.php
+++ b/src/applications/phriction/storage/PhrictionDocument.php
@@ -61,7 +61,7 @@
$document = new PhrictionDocument();
$document->setSlug($slug);
- $content = new PhrictionContent();
+ $content = new PhrictionContent();
$content->setSlug($slug);
$default_title = PhabricatorSlug::getDefaultTitle($slug);

File Metadata

Mime Type
text/plain
Expires
Fri, Feb 28, 10:09 PM (11 h, 58 m)
Storage Engine
blob
Storage Format
Encrypted (AES-256-CBC)
Storage Handle
7214636
Default Alt Text
D19095.id45761.diff (6 KB)

Event Timeline