@recaptime-dev's working patches + fork for Phorge, a community fork of Phabricator. (Upstream dev and stable branches are at upstream/main and upstream/stable respectively.) hq.recaptime.dev/wiki/Phorge
phorge phabricator
1
fork

Configure Feed

Select the types of activity you want to include in your feed.

Mostly use PhrictionContentQuery to load PhrictionContent objects

Summary: Depends on D19094. Ref T13077. Use modern infrastructure to perform these loads. I left a couple of calls in the older API methods unconverted.

Test Plan: Viewed documents. Viewed older versions. Viewed diffs. Did revert edits to older versions.

Maniphest Tasks: T13077

Differential Revision: https://secure.phabricator.com/D19095

+49 -28
+5 -4
src/applications/phriction/controller/PhrictionDiffController.php
··· 29 29 list($l, $r) = explode(',', $ref); 30 30 } 31 31 32 - $content = id(new PhrictionContent())->loadAllWhere( 33 - 'documentID = %d AND version IN (%Ld)', 34 - $document->getID(), 35 - array($l, $r)); 32 + $content = id(new PhrictionContentQuery()) 33 + ->setViewer($viewer) 34 + ->withDocumentPHIDs(array($document->getPHID())) 35 + ->withVersions(array($l, $r)) 36 + ->execute(); 36 37 $content = mpull($content, null, 'getVersion'); 37 38 38 39 $content_l = idx($content, $l, null);
+19 -16
src/applications/phriction/controller/PhrictionDocumentController.php
··· 22 22 23 23 require_celerity_resource('phriction-document-css'); 24 24 25 - $document = id(new PhrictionDocumentQuery()) 26 - ->setViewer($viewer) 27 - ->withSlugs(array($slug)) 28 - ->executeOne(); 29 - 30 25 $version_note = null; 31 26 $core_content = ''; 32 27 $move_notice = ''; ··· 34 29 $content = null; 35 30 $toc = null; 36 31 32 + $document = id(new PhrictionDocumentQuery()) 33 + ->setViewer($viewer) 34 + ->withSlugs(array($slug)) 35 + ->needContent(true) 36 + ->executeOne(); 37 37 if (!$document) { 38 38 39 39 $document = PhrictionDocument::initializeNewDocument($viewer, $slug); ··· 69 69 $version = $request->getInt('v'); 70 70 71 71 if ($version) { 72 - $content = id(new PhrictionContent())->loadOneWhere( 73 - 'documentID = %d AND version = %d', 74 - $document->getID(), 75 - $version); 72 + $content = id(new PhrictionContentQuery()) 73 + ->setViewer($viewer) 74 + ->withDocumentPHIDs(array($document->getPHID())) 75 + ->withVersions(array($version)) 76 + ->executeOne(); 76 77 if (!$content) { 77 78 return new Aphront404Response(); 78 79 } 79 80 80 81 if ($content->getID() != $document->getContentID()) { 81 - $vdate = phabricator_datetime($content->getDateCreated(), $viewer); 82 - $version_note = new PHUIInfoView(); 83 - $version_note->setSeverity(PHUIInfoView::SEVERITY_NOTICE); 84 - $version_note->appendChild( 85 - pht('You are viewing an older version of this document, as it '. 86 - 'appeared on %s.', $vdate)); 82 + $version_note = id(new PHUIInfoView()) 83 + ->setSeverity(PHUIInfoView::SEVERITY_NOTICE) 84 + ->appendChild( 85 + pht( 86 + 'You are viewing an older version of this document, as it '. 87 + 'appeared on %s.', 88 + phabricator_datetime($content->getDateCreated(), $viewer))); 87 89 } 88 90 } else { 89 - $content = id(new PhrictionContent())->load($document->getContentID()); 91 + $content = $document->getContent(); 90 92 } 93 + 91 94 $page_title = $content->getTitle(); 92 95 $properties = $this 93 96 ->buildPropertyListView($document, $content, $slug);
+5 -4
src/applications/phriction/controller/PhrictionEditController.php
··· 28 28 29 29 $revert = $request->getInt('revert'); 30 30 if ($revert) { 31 - $content = id(new PhrictionContent())->loadOneWhere( 32 - 'documentID = %d AND version = %d', 33 - $document->getID(), 34 - $revert); 31 + $content = id(new PhrictionContentQuery()) 32 + ->setViewer($viewer) 33 + ->withDocumentPHIDs(array($document->getPHID())) 34 + ->withVersions(array($revert)) 35 + ->executeOne(); 35 36 if (!$content) { 36 37 return new Aphront404Response(); 37 38 }
+13
src/applications/phriction/query/PhrictionContentQuery.php
··· 6 6 private $ids; 7 7 private $phids; 8 8 private $documentPHIDs; 9 + private $versions; 9 10 10 11 public function withIDs(array $ids) { 11 12 $this->ids = $ids; ··· 19 20 20 21 public function withDocumentPHIDs(array $phids) { 21 22 $this->documentPHIDs = $phids; 23 + return $this; 24 + } 25 + 26 + public function withVersions(array $versions) { 27 + $this->versions = $versions; 22 28 return $this; 23 29 } 24 30 ··· 45 51 $conn, 46 52 'c.phid IN (%Ls)', 47 53 $this->phids); 54 + } 55 + 56 + if ($this->versions !== null) { 57 + $where[] = qsprintf( 58 + $conn, 59 + 'version IN (%Ld)', 60 + $this->versions); 48 61 } 49 62 50 63 if ($this->documentPHIDs !== null) {
+6 -3
src/applications/phriction/query/PhrictionDocumentQuery.php
··· 145 145 } 146 146 147 147 if ($this->needContent) { 148 - $contents = id(new PhrictionContent())->loadAllWhere( 149 - 'id IN (%Ld)', 150 - mpull($documents, 'getContentID')); 148 + $contents = id(new PhrictionContentQuery()) 149 + ->setViewer($this->getViewer()) 150 + ->setParentQuery($this) 151 + ->withIDs(mpull($documents, 'getContentID')) 152 + ->execute(); 153 + $contents = mpull($contents, null, 'getID'); 151 154 152 155 foreach ($documents as $key => $document) { 153 156 $content_id = $document->getContentID();
+1 -1
src/applications/phriction/storage/PhrictionDocument.php
··· 61 61 $document = new PhrictionDocument(); 62 62 $document->setSlug($slug); 63 63 64 - $content = new PhrictionContent(); 64 + $content = new PhrictionContent(); 65 65 $content->setSlug($slug); 66 66 67 67 $default_title = PhabricatorSlug::getDefaultTitle($slug);