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

Give PhrictionContent objects (older versions of wiki pages) legitimate PHIDs

Summary: Ref T13077. Prepares for modern API access to document history using standard "v3" APIs.

Test Plan: Ran migration, verified PHIDs appeared in the database. Created/edited a document, got even more PHIDs in the database.

Maniphest Tasks: T13077

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

+119 -1
+2
resources/sql/autopatches/20180215.phriction.01.phidcol.sql
··· 1 + ALTER TABLE {$NAMESPACE}_phriction.phriction_content 2 + ADD phid VARBINARY(64) NOT NULL;
+17
resources/sql/autopatches/20180215.phriction.02.phidvalues.php
··· 1 + <?php 2 + 3 + $table = new PhrictionContent(); 4 + $conn = $table->establishConnection('w'); 5 + 6 + foreach (new LiskMigrationIterator($table) as $row) { 7 + if (strlen($row->getPHID())) { 8 + continue; 9 + } 10 + 11 + queryfx( 12 + $conn, 13 + 'UPDATE %T SET phid = %s WHERE id = %d', 14 + $table->getTableName(), 15 + $table->generatePHID(), 16 + $row->getID()); 17 + }
+4
src/__phutil_library_map__.php
··· 4845 4845 'PhrictionConduitAPIMethod' => 'applications/phriction/conduit/PhrictionConduitAPIMethod.php', 4846 4846 'PhrictionConstants' => 'applications/phriction/constants/PhrictionConstants.php', 4847 4847 'PhrictionContent' => 'applications/phriction/storage/PhrictionContent.php', 4848 + 'PhrictionContentPHIDType' => 'applications/phriction/phid/PhrictionContentPHIDType.php', 4849 + 'PhrictionContentQuery' => 'applications/phriction/query/PhrictionContentQuery.php', 4848 4850 'PhrictionController' => 'applications/phriction/controller/PhrictionController.php', 4849 4851 'PhrictionCreateConduitAPIMethod' => 'applications/phriction/conduit/PhrictionCreateConduitAPIMethod.php', 4850 4852 'PhrictionDAO' => 'applications/phriction/storage/PhrictionDAO.php', ··· 10757 10759 'PhrictionDAO', 10758 10760 'PhabricatorMarkupInterface', 10759 10761 ), 10762 + 'PhrictionContentPHIDType' => 'PhabricatorPHIDType', 10763 + 'PhrictionContentQuery' => 'PhabricatorCursorPagedPolicyAwareQuery', 10760 10764 'PhrictionController' => 'PhabricatorController', 10761 10765 'PhrictionCreateConduitAPIMethod' => 'PhrictionConduitAPIMethod', 10762 10766 'PhrictionDAO' => 'PhabricatorLiskDAO',
+38
src/applications/phriction/phid/PhrictionContentPHIDType.php
··· 1 + <?php 2 + 3 + final class PhrictionContentPHIDType 4 + extends PhabricatorPHIDType { 5 + 6 + const TYPECONST = 'WRDS'; 7 + 8 + public function getTypeName() { 9 + return pht('Phriction Content'); 10 + } 11 + 12 + public function newObject() { 13 + return new PhrictionContent(); 14 + } 15 + 16 + public function getPHIDTypeApplicationClass() { 17 + return 'PhabricatorPhrictionApplication'; 18 + } 19 + 20 + protected function buildQueryForObjects( 21 + PhabricatorObjectQuery $query, 22 + array $phids) { 23 + 24 + return id(new PhrictionContentQuery()) 25 + ->withPHIDs($phids); 26 + } 27 + 28 + public function loadHandles( 29 + PhabricatorHandleQuery $query, 30 + array $handles, 31 + array $objects) { 32 + 33 + foreach ($handles as $phid => $handle) { 34 + $content = $objects[$phid]; 35 + } 36 + } 37 + 38 + }
+51
src/applications/phriction/query/PhrictionContentQuery.php
··· 1 + <?php 2 + 3 + final class PhrictionContentQuery 4 + extends PhabricatorCursorPagedPolicyAwareQuery { 5 + 6 + private $ids; 7 + private $phids; 8 + 9 + public function withIDs(array $ids) { 10 + $this->ids = $ids; 11 + return $this; 12 + } 13 + 14 + public function withPHIDs(array $phids) { 15 + $this->phids = $phids; 16 + return $this; 17 + } 18 + 19 + public function newResultObject() { 20 + return new PhrictionContent(); 21 + } 22 + 23 + protected function loadPage() { 24 + return $this->loadStandardPage($this->newResultObject()); 25 + } 26 + 27 + protected function buildWhereClauseParts(AphrontDatabaseConnection $conn) { 28 + $where = parent::buildWhereClauseParts($conn); 29 + 30 + if ($this->ids !== null) { 31 + $where[] = qsprintf( 32 + $conn, 33 + 'id IN (%Ld)', 34 + $this->ids); 35 + } 36 + 37 + if ($this->phids !== null) { 38 + $where[] = qsprintf( 39 + $conn, 40 + 'phid IN (%Ls)', 41 + $this->phids); 42 + } 43 + 44 + return $where; 45 + } 46 + 47 + public function getQueryApplicationClass() { 48 + return 'PhabricatorPhrictionApplication'; 49 + } 50 + 51 + }
+7 -1
src/applications/phriction/storage/PhrictionContent.php
··· 3 3 /** 4 4 * @task markup Markup Interface 5 5 */ 6 - final class PhrictionContent extends PhrictionDAO 6 + final class PhrictionContent 7 + extends PhrictionDAO 7 8 implements PhabricatorMarkupInterface { 8 9 9 10 const MARKUP_FIELD_BODY = 'markup:body'; ··· 33 34 34 35 protected function getConfiguration() { 35 36 return array( 37 + self::CONFIG_AUX_PHID => true, 36 38 self::CONFIG_COLUMN_SCHEMA => array( 37 39 'version' => 'uint32', 38 40 'title' => 'sort', ··· 58 60 ), 59 61 ), 60 62 ) + parent::getConfiguration(); 63 + } 64 + 65 + public function getPHIDType() { 66 + return PhrictionContentPHIDType::TYPECONST; 61 67 } 62 68 63 69