mirror of
https://we.phorge.it/source/phorge.git
synced 2024-11-22 14:52:41 +01:00
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
This commit is contained in:
parent
463dda98ed
commit
e492c717c6
6 changed files with 119 additions and 1 deletions
|
@ -0,0 +1,2 @@
|
|||
ALTER TABLE {$NAMESPACE}_phriction.phriction_content
|
||||
ADD phid VARBINARY(64) NOT NULL;
|
|
@ -0,0 +1,17 @@
|
|||
<?php
|
||||
|
||||
$table = new PhrictionContent();
|
||||
$conn = $table->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());
|
||||
}
|
|
@ -4845,6 +4845,8 @@ phutil_register_library_map(array(
|
|||
'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 @@ phutil_register_library_map(array(
|
|||
'PhrictionDAO',
|
||||
'PhabricatorMarkupInterface',
|
||||
),
|
||||
'PhrictionContentPHIDType' => 'PhabricatorPHIDType',
|
||||
'PhrictionContentQuery' => 'PhabricatorCursorPagedPolicyAwareQuery',
|
||||
'PhrictionController' => 'PhabricatorController',
|
||||
'PhrictionCreateConduitAPIMethod' => 'PhrictionConduitAPIMethod',
|
||||
'PhrictionDAO' => 'PhabricatorLiskDAO',
|
||||
|
|
38
src/applications/phriction/phid/PhrictionContentPHIDType.php
Normal file
38
src/applications/phriction/phid/PhrictionContentPHIDType.php
Normal file
|
@ -0,0 +1,38 @@
|
|||
<?php
|
||||
|
||||
final class PhrictionContentPHIDType
|
||||
extends PhabricatorPHIDType {
|
||||
|
||||
const TYPECONST = 'WRDS';
|
||||
|
||||
public function getTypeName() {
|
||||
return pht('Phriction Content');
|
||||
}
|
||||
|
||||
public function newObject() {
|
||||
return new PhrictionContent();
|
||||
}
|
||||
|
||||
public function getPHIDTypeApplicationClass() {
|
||||
return 'PhabricatorPhrictionApplication';
|
||||
}
|
||||
|
||||
protected function buildQueryForObjects(
|
||||
PhabricatorObjectQuery $query,
|
||||
array $phids) {
|
||||
|
||||
return id(new PhrictionContentQuery())
|
||||
->withPHIDs($phids);
|
||||
}
|
||||
|
||||
public function loadHandles(
|
||||
PhabricatorHandleQuery $query,
|
||||
array $handles,
|
||||
array $objects) {
|
||||
|
||||
foreach ($handles as $phid => $handle) {
|
||||
$content = $objects[$phid];
|
||||
}
|
||||
}
|
||||
|
||||
}
|
51
src/applications/phriction/query/PhrictionContentQuery.php
Normal file
51
src/applications/phriction/query/PhrictionContentQuery.php
Normal file
|
@ -0,0 +1,51 @@
|
|||
<?php
|
||||
|
||||
final class PhrictionContentQuery
|
||||
extends PhabricatorCursorPagedPolicyAwareQuery {
|
||||
|
||||
private $ids;
|
||||
private $phids;
|
||||
|
||||
public function withIDs(array $ids) {
|
||||
$this->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';
|
||||
}
|
||||
|
||||
}
|
|
@ -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 @@ final class PhrictionContent extends PhrictionDAO
|
|||
|
||||
protected function getConfiguration() {
|
||||
return array(
|
||||
self::CONFIG_AUX_PHID => true,
|
||||
self::CONFIG_COLUMN_SCHEMA => array(
|
||||
'version' => 'uint32',
|
||||
'title' => 'sort',
|
||||
|
@ -60,6 +62,10 @@ final class PhrictionContent extends PhrictionDAO
|
|||
) + parent::getConfiguration();
|
||||
}
|
||||
|
||||
public function getPHIDType() {
|
||||
return PhrictionContentPHIDType::TYPECONST;
|
||||
}
|
||||
|
||||
|
||||
/* -( Markup Interface )--------------------------------------------------- */
|
||||
|
||||
|
|
Loading…
Reference in a new issue