@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.

Use application PHIDs in Phriction

Summary: Ref T2715. Moves Phriction to application PHIDs.

Test Plan: Used `phid.query`; browsed Phriction.

Reviewers: btrahan

Reviewed By: btrahan

CC: aran

Maniphest Tasks: T2715

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

+93 -70
+2
src/__phutil_library_map__.php
··· 1840 1840 'PhrictionListController' => 'applications/phriction/controller/PhrictionListController.php', 1841 1841 'PhrictionMoveController' => 'applications/phriction/controller/PhrictionMoveController.php', 1842 1842 'PhrictionNewController' => 'applications/phriction/controller/PhrictionNewController.php', 1843 + 'PhrictionPHIDTypeDocument' => 'applications/phriction/phid/PhrictionPHIDTypeDocument.php', 1843 1844 'PhrictionRemarkupRule' => 'applications/phriction/remarkup/PhrictionRemarkupRule.php', 1844 1845 'PhrictionSearchIndexer' => 'applications/phriction/search/PhrictionSearchIndexer.php', 1845 1846 'PonderAddAnswerView' => 'applications/ponder/view/PonderAddAnswerView.php', ··· 3912 3913 'PhrictionListController' => 'PhrictionController', 3913 3914 'PhrictionMoveController' => 'PhrictionController', 3914 3915 'PhrictionNewController' => 'PhrictionController', 3916 + 'PhrictionPHIDTypeDocument' => 'PhabricatorPHIDType', 3915 3917 'PhrictionRemarkupRule' => 'PhutilRemarkupRule', 3916 3918 'PhrictionSearchIndexer' => 'PhabricatorSearchDocumentIndexer', 3917 3919 'PonderAddAnswerView' => 'AphrontView',
-1
src/applications/phid/PhabricatorObjectHandle.php
··· 109 109 110 110 static $map = array( 111 111 PhabricatorPHIDConstants::PHID_TYPE_USER => 'User', 112 - PhabricatorPHIDConstants::PHID_TYPE_WIKI => 'Phriction Document', 113 112 PhabricatorPHIDConstants::PHID_TYPE_MCRO => 'Image Macro', 114 113 PhabricatorPHIDConstants::PHID_TYPE_PIMG => 'Pholio Image', 115 114 PhabricatorPHIDConstants::PHID_TYPE_BLOG => 'Blog',
-1
src/applications/phid/PhabricatorPHIDConstants.php
··· 8 8 const PHID_TYPE_OPKG = 'OPKG'; 9 9 const PHID_TYPE_PSTE = 'PSTE'; 10 10 const PHID_TYPE_STRY = 'STRY'; 11 - const PHID_TYPE_WIKI = 'WIKI'; 12 11 const PHID_TYPE_APRJ = 'APRJ'; 13 12 const PHID_TYPE_ACMT = 'ACMT'; 14 13 const PHID_TYPE_DRYR = 'DRYR';
-46
src/applications/phid/handle/PhabricatorObjectHandleData.php
··· 68 68 $phids); 69 69 return mpull($projects, null, 'getPHID'); 70 70 71 - case PhabricatorPHIDConstants::PHID_TYPE_WIKI: 72 - // TODO: Update this to PhrictionDocumentQuery, already pre-package 73 - // content DAO 74 - $document_dao = new PhrictionDocument(); 75 - $documents = $document_dao->loadAllWhere( 76 - 'phid IN (%Ls)', 77 - $phids); 78 - return mpull($documents, null, 'getPHID'); 79 - 80 71 case PhabricatorPHIDConstants::PHID_TYPE_QUES: 81 72 $questions = id(new PonderQuestionQuery()) 82 73 ->setViewer($this->viewer) ··· 304 295 $project = $objects[$phid]; 305 296 $handle->setName($project->getName()); 306 297 $handle->setComplete(true); 307 - } 308 - $handles[$phid] = $handle; 309 - } 310 - break; 311 - 312 - case PhabricatorPHIDConstants::PHID_TYPE_WIKI: 313 - // TODO: Update this 314 - $document_dao = new PhrictionDocument(); 315 - $content_dao = new PhrictionContent(); 316 - 317 - $conn = $document_dao->establishConnection('r'); 318 - $documents = queryfx_all( 319 - $conn, 320 - 'SELECT * FROM %T document JOIN %T content 321 - ON document.contentID = content.id 322 - WHERE document.phid IN (%Ls)', 323 - $document_dao->getTableName(), 324 - $content_dao->getTableName(), 325 - $phids); 326 - $documents = ipull($documents, null, 'phid'); 327 - 328 - foreach ($phids as $phid) { 329 - $handle = new PhabricatorObjectHandle(); 330 - $handle->setPHID($phid); 331 - $handle->setType($type); 332 - if (empty($documents[$phid])) { 333 - $handle->setName('Unknown Document'); 334 - } else { 335 - $info = $documents[$phid]; 336 - $handle->setName($info['title']); 337 - $handle->setURI(PhrictionDocument::getSlugURI($info['slug'])); 338 - $handle->setFullName($info['title']); 339 - $handle->setComplete(true); 340 - if ($info['status'] != PhrictionDocumentStatus::STATUS_EXISTS) { 341 - $closed = PhabricatorObjectHandleStatus::STATUS_CLOSED; 342 - $handle->setStatus($closed); 343 - } 344 298 } 345 299 $handles[$phid] = $handle; 346 300 }
+4 -3
src/applications/phriction/controller/PhrictionDocumentController.php
··· 25 25 26 26 require_celerity_resource('phriction-document-css'); 27 27 28 - $document = id(new PhrictionDocument())->loadOneWhere( 29 - 'slug = %s', 30 - $slug); 28 + $document = id(new PhrictionDocumentQuery()) 29 + ->setViewer($user) 30 + ->withSlugs(array($slug)) 31 + ->executeOne(); 31 32 32 33 $version_note = null; 33 34 $core_content = '';
+55
src/applications/phriction/phid/PhrictionPHIDTypeDocument.php
··· 1 + <?php 2 + 3 + final class PhrictionPHIDTypeDocument extends PhabricatorPHIDType { 4 + 5 + const TYPECONST = 'WIKI'; 6 + 7 + public function getTypeConstant() { 8 + return self::TYPECONST; 9 + } 10 + 11 + public function getTypeName() { 12 + return pht('Wiki Document'); 13 + } 14 + 15 + public function newObject() { 16 + return new PhrictionDocument(); 17 + } 18 + 19 + public function loadObjects( 20 + PhabricatorObjectQuery $query, 21 + array $phids) { 22 + 23 + return id(new PhrictionDocumentQuery()) 24 + ->setViewer($query->getViewer()) 25 + ->withPHIDs($phids) 26 + ->execute(); 27 + } 28 + 29 + public function loadHandles( 30 + PhabricatorHandleQuery $query, 31 + array $handles, 32 + array $objects) { 33 + 34 + foreach ($handles as $phid => $handle) { 35 + $document = $objects[$phid]; 36 + $content = $document->getContent(); 37 + 38 + $title = $content->getTitle(); 39 + $slug = $document->getSlug(); 40 + $status = $document->getStatus(); 41 + 42 + $handle->setName($title); 43 + $handle->setURI(PhrictionDocument::getSlugURI($slug)); 44 + 45 + if ($status != PhrictionDocumentStatus::STATUS_EXISTS) { 46 + $handle->setStatus(PhabricatorObjectHandleStatus::STATUS_CLOSED); 47 + } 48 + } 49 + } 50 + 51 + public function canLoadNamedObject($name) { 52 + return false; 53 + } 54 + 55 + }
+18 -1
src/applications/phriction/query/PhrictionDocumentQuery.php
··· 8 8 9 9 private $ids; 10 10 private $phids; 11 + private $slugs; 11 12 12 13 private $status = 'status-any'; 13 14 const STATUS_ANY = 'status-any'; ··· 25 26 26 27 public function withPHIDs(array $phids) { 27 28 $this->phids = $phids; 29 + return $this; 30 + } 31 + 32 + public function withSlugs(array $slugs) { 33 + $this->slugs = $slugs; 28 34 return $this; 29 35 } 30 36 ··· 69 75 continue; 70 76 } 71 77 $document->attachContent($contents[$content_id]); 78 + } 79 + 80 + foreach ($documents as $document) { 81 + $document->attachProject(null); 72 82 } 73 83 74 84 $project_slugs = array(); ··· 115 125 if ($this->phids) { 116 126 $where[] = qsprintf( 117 127 $conn, 118 - 'id IN (%Ld)', 128 + 'phid IN (%Ls)', 119 129 $this->phids); 130 + } 131 + 132 + if ($this->slugs) { 133 + $where[] = qsprintf( 134 + $conn, 135 + 'slug IN (%Ls)', 136 + $this->slugs); 120 137 } 121 138 122 139 switch ($this->status) {
+2 -2
src/applications/phriction/search/PhrictionSearchIndexer.php
··· 20 20 21 21 $doc = new PhabricatorSearchAbstractDocument(); 22 22 $doc->setPHID($document->getPHID()); 23 - $doc->setDocumentType(PhabricatorPHIDConstants::PHID_TYPE_WIKI); 23 + $doc->setDocumentType(PhrictionPHIDTypeDocument::TYPECONST); 24 24 $doc->setDocumentTitle($content->getTitle()); 25 25 26 26 // TODO: This isn't precisely correct, denormalize into the Document table? ··· 41 41 $doc->addRelationship( 42 42 PhabricatorSearchRelationship::RELATIONSHIP_OPEN, 43 43 $document->getPHID(), 44 - PhabricatorPHIDConstants::PHID_TYPE_WIKI, 44 + PhrictionPHIDTypeDocument::TYPECONST, 45 45 time()); 46 46 } 47 47
+10 -13
src/applications/phriction/storage/PhrictionDocument.php
··· 16 16 protected $contentID; 17 17 protected $status; 18 18 19 - private $contentObject; 20 - private $project; 19 + private $contentObject = self::ATTACHABLE; 20 + 21 + // TODO: This should be `self::ATTACHABLE`, but there are still a lot of call 22 + // sites which load PhrictionDocuments directly. 23 + private $project = null; 21 24 22 25 public function getConfiguration() { 23 26 return array( ··· 28 31 29 32 public function generatePHID() { 30 33 return PhabricatorPHID::generateNewPHID( 31 - PhabricatorPHIDConstants::PHID_TYPE_WIKI); 34 + PhrictionPHIDTypeDocument::TYPECONST); 32 35 } 33 36 34 37 public static function getSlugURI($slug, $type = 'document') { ··· 66 69 } 67 70 68 71 public function getContent() { 69 - if (!$this->contentObject) { 70 - throw new Exception("Attach content with attachContent() first."); 71 - } 72 - return $this->contentObject; 72 + return $this->assertAttached($this->contentObject); 73 73 } 74 74 75 75 public function getProject() { 76 - if ($this->project === null) { 77 - throw new Exception("Call attachProject() before getProject()."); 78 - } 79 - return $this->project; 76 + return $this->assertAttached($this->project); 80 77 } 81 78 82 - public function attachProject(PhabricatorProject $project) { 79 + public function attachProject(PhabricatorProject $project = null) { 83 80 $this->project = $project; 84 81 return $this; 85 82 } 86 83 87 84 public function hasProject() { 88 - return (bool)$this->project; 85 + return (bool)$this->getProject(); 89 86 } 90 87 91 88 public static function isProjectSlug($slug) {
+1 -1
src/applications/search/controller/PhabricatorSearchController.php
··· 58 58 case PhabricatorSearchScope::SCOPE_WIKI: 59 59 $query->setParameter( 60 60 'type', 61 - PhabricatorPHIDConstants::PHID_TYPE_WIKI); 61 + PhrictionPHIDTypeDocument::TYPECONST); 62 62 break; 63 63 case PhabricatorSearchScope::SCOPE_COMMITS: 64 64 $query->setParameter(
+1 -1
src/applications/search/index/PhabricatorSearchAbstractDocument.php
··· 18 18 DifferentialPHIDTypeRevision::TYPECONST => 'Differential Revisions', 19 19 PhabricatorRepositoryPHIDTypeCommit::TYPECONST => 'Repository Commits', 20 20 ManiphestPHIDTypeTask::TYPECONST => 'Maniphest Tasks', 21 - PhabricatorPHIDConstants::PHID_TYPE_WIKI => 'Phriction Documents', 21 + PhrictionPHIDTypeDocument::TYPECONST => 'Phriction Documents', 22 22 PhabricatorPHIDConstants::PHID_TYPE_USER => 'Phabricator Users', 23 23 PhabricatorPHIDConstants::PHID_TYPE_QUES => 'Ponder Questions', 24 24 );
-1
src/infrastructure/edges/constants/PhabricatorEdgeConfig.php
··· 162 162 PhabricatorPHIDConstants::PHID_TYPE_ANSW => 'PonderAnswer', 163 163 PhabricatorPHIDConstants::PHID_TYPE_MCRO => 'PhabricatorFileImageMacro', 164 164 PhabricatorPHIDConstants::PHID_TYPE_CONP => 'ConpherenceThread', 165 - PhabricatorPHIDConstants::PHID_TYPE_WIKI => 'PhrictionDocument', 166 165 PhabricatorPHIDConstants::PHID_TYPE_ACNT => 'PhortuneAccount', 167 166 PhabricatorPHIDConstants::PHID_TYPE_PRCH => 'PhortunePurchase', 168 167 PhabricatorPHIDConstants::PHID_TYPE_CHRG => 'PhortuneCharge',