diff --git a/resources/sql/autopatches/20180215.phriction.01.phidcol.sql b/resources/sql/autopatches/20180215.phriction.01.phidcol.sql new file mode 100644 --- /dev/null +++ b/resources/sql/autopatches/20180215.phriction.01.phidcol.sql @@ -0,0 +1,2 @@ +ALTER TABLE {$NAMESPACE}_phriction.phriction_content + ADD phid VARBINARY(64) NOT NULL; diff --git a/resources/sql/autopatches/20180215.phriction.02.phidvalues.php b/resources/sql/autopatches/20180215.phriction.02.phidvalues.php new file mode 100644 --- /dev/null +++ b/resources/sql/autopatches/20180215.phriction.02.phidvalues.php @@ -0,0 +1,17 @@ +establishConnection('w'); + +foreach (new LiskMigrationIterator($table) as $row) { + if (strlen($row->getPHID())) { + continue; + } + + queryfx( + $conn, + 'UPDATE %T SET phid = %s WHERE id = %d', + $table->getTableName(), + $table->generatePHID(), + $row->getID()); +} diff --git a/src/__phutil_library_map__.php b/src/__phutil_library_map__.php --- a/src/__phutil_library_map__.php +++ b/src/__phutil_library_map__.php @@ -4845,6 +4845,8 @@ 'PhrictionConduitAPIMethod' => 'applications/phriction/conduit/PhrictionConduitAPIMethod.php', 'PhrictionConstants' => 'applications/phriction/constants/PhrictionConstants.php', 'PhrictionContent' => 'applications/phriction/storage/PhrictionContent.php', + 'PhrictionContentPHIDType' => 'applications/phriction/phid/PhrictionContentPHIDType.php', + 'PhrictionContentQuery' => 'applications/phriction/query/PhrictionContentQuery.php', 'PhrictionController' => 'applications/phriction/controller/PhrictionController.php', 'PhrictionCreateConduitAPIMethod' => 'applications/phriction/conduit/PhrictionCreateConduitAPIMethod.php', 'PhrictionDAO' => 'applications/phriction/storage/PhrictionDAO.php', @@ -10757,6 +10759,8 @@ 'PhrictionDAO', 'PhabricatorMarkupInterface', ), + 'PhrictionContentPHIDType' => 'PhabricatorPHIDType', + 'PhrictionContentQuery' => 'PhabricatorCursorPagedPolicyAwareQuery', 'PhrictionController' => 'PhabricatorController', 'PhrictionCreateConduitAPIMethod' => 'PhrictionConduitAPIMethod', 'PhrictionDAO' => 'PhabricatorLiskDAO', diff --git a/src/applications/phriction/phid/PhrictionContentPHIDType.php b/src/applications/phriction/phid/PhrictionContentPHIDType.php new file mode 100644 --- /dev/null +++ b/src/applications/phriction/phid/PhrictionContentPHIDType.php @@ -0,0 +1,38 @@ +withPHIDs($phids); + } + + public function loadHandles( + PhabricatorHandleQuery $query, + array $handles, + array $objects) { + + foreach ($handles as $phid => $handle) { + $content = $objects[$phid]; + } + } + +} diff --git a/src/applications/phriction/query/PhrictionContentQuery.php b/src/applications/phriction/query/PhrictionContentQuery.php new file mode 100644 --- /dev/null +++ b/src/applications/phriction/query/PhrictionContentQuery.php @@ -0,0 +1,51 @@ +ids = $ids; + return $this; + } + + public function withPHIDs(array $phids) { + $this->phids = $phids; + return $this; + } + + public function newResultObject() { + return new PhrictionContent(); + } + + protected function loadPage() { + return $this->loadStandardPage($this->newResultObject()); + } + + protected function buildWhereClauseParts(AphrontDatabaseConnection $conn) { + $where = parent::buildWhereClauseParts($conn); + + if ($this->ids !== null) { + $where[] = qsprintf( + $conn, + 'id IN (%Ld)', + $this->ids); + } + + if ($this->phids !== null) { + $where[] = qsprintf( + $conn, + 'phid IN (%Ls)', + $this->phids); + } + + return $where; + } + + public function getQueryApplicationClass() { + return 'PhabricatorPhrictionApplication'; + } + +} diff --git a/src/applications/phriction/storage/PhrictionContent.php b/src/applications/phriction/storage/PhrictionContent.php --- a/src/applications/phriction/storage/PhrictionContent.php +++ b/src/applications/phriction/storage/PhrictionContent.php @@ -3,7 +3,8 @@ /** * @task markup Markup Interface */ -final class PhrictionContent extends PhrictionDAO +final class PhrictionContent + extends PhrictionDAO implements PhabricatorMarkupInterface { const MARKUP_FIELD_BODY = 'markup:body'; @@ -33,6 +34,7 @@ protected function getConfiguration() { return array( + self::CONFIG_AUX_PHID => true, self::CONFIG_COLUMN_SCHEMA => array( 'version' => 'uint32', 'title' => 'sort', @@ -60,6 +62,10 @@ ) + parent::getConfiguration(); } + public function getPHIDType() { + return PhrictionContentPHIDType::TYPECONST; + } + /* -( Markup Interface )--------------------------------------------------- */