1
0
Fork 0
mirror of https://we.phorge.it/source/phorge.git synced 2024-11-18 12:52:42 +01:00

Add spacePHID infrastructure and implement in Paste

Summary:
Ref T8424. I'm using Paste as a testbed application because Spaces make some degree of sense for it but it's also flat/simple.

This doesn't do anything interesting or useful and mostly just making the next (more interesting) diff smaller.

Test Plan:
  - Ran `bin/storage upgrade -f`.
  - Browsed pastes.
  - Created a paste.

Reviewers: btrahan

Reviewed By: btrahan

Subscribers: epriestley

Maniphest Tasks: T8424

Differential Revision: https://secure.phabricator.com/D13154
This commit is contained in:
epriestley 2015-06-04 17:45:24 -07:00
parent 52a29be70d
commit 763b63a0fb
6 changed files with 50 additions and 14 deletions

View file

@ -0,0 +1,2 @@
ALTER TABLE {$NAMESPACE}_pastebin.pastebin_paste
ADD spacePHID VARBINARY(64);

View file

@ -5615,6 +5615,7 @@ phutil_register_library_map(array(
'PhabricatorProjectInterface',
'PhabricatorDestructibleInterface',
'PhabricatorApplicationTransactionInterface',
'PhabricatorSpacesInterface',
),
'PhabricatorPasteApplication' => 'PhabricatorApplication',
'PhabricatorPasteCommentController' => 'PhabricatorPasteController',

View file

@ -96,61 +96,59 @@ final class PhabricatorPasteQuery
return $pastes;
}
protected function buildWhereClause(AphrontDatabaseConnection $conn_r) {
$where = array();
$where[] = $this->buildPagingClause($conn_r);
protected function buildWhereClauseParts(AphrontDatabaseConnection $conn) {
$where = parent::buildWhereClauseParts($conn);
if ($this->ids) {
$where[] = qsprintf(
$conn_r,
$conn,
'id IN (%Ld)',
$this->ids);
}
if ($this->phids) {
$where[] = qsprintf(
$conn_r,
$conn,
'phid IN (%Ls)',
$this->phids);
}
if ($this->authorPHIDs) {
$where[] = qsprintf(
$conn_r,
$conn,
'authorPHID IN (%Ls)',
$this->authorPHIDs);
}
if ($this->parentPHIDs) {
$where[] = qsprintf(
$conn_r,
$conn,
'parentPHID IN (%Ls)',
$this->parentPHIDs);
}
if ($this->languages) {
$where[] = qsprintf(
$conn_r,
$conn,
'language IN (%Ls)',
$this->languages);
}
if ($this->dateCreatedAfter) {
$where[] = qsprintf(
$conn_r,
$conn,
'dateCreated >= %d',
$this->dateCreatedAfter);
}
if ($this->dateCreatedBefore) {
$where[] = qsprintf(
$conn_r,
$conn,
'dateCreated <= %d',
$this->dateCreatedBefore);
}
return $this->formatWhereClause($where);
return $where;
}
private function getContentCacheKey(PhabricatorPaste $paste) {

View file

@ -9,7 +9,8 @@ final class PhabricatorPaste extends PhabricatorPasteDAO
PhabricatorPolicyInterface,
PhabricatorProjectInterface,
PhabricatorDestructibleInterface,
PhabricatorApplicationTransactionInterface {
PhabricatorApplicationTransactionInterface,
PhabricatorSpacesInterface {
protected $title;
protected $authorPHID;
@ -19,6 +20,7 @@ final class PhabricatorPaste extends PhabricatorPasteDAO
protected $viewPolicy;
protected $editPolicy;
protected $mailKey;
protected $spacePHID;
private $content = self::ATTACHABLE;
private $rawContent = self::ATTACHABLE;
@ -206,4 +208,12 @@ final class PhabricatorPaste extends PhabricatorPasteDAO
return $timeline;
}
/* -( PhabricatorSpacesInterface )----------------------------------------- */
public function getSpacePHID() {
return $this->spacePHID;
}
}

View file

@ -1,3 +1,18 @@
<?php
interface PhabricatorSpacesInterface extends PhabricatorPHIDInterface {}
interface PhabricatorSpacesInterface extends PhabricatorPHIDInterface {
public function getSpacePHID();
}
// TEMPLATE IMPLEMENTATION /////////////////////////////////////////////////////
/* -( PhabricatorSpacesInterface )----------------------------------------- */
/*
public function getSpacePHID() {
return $this->spacePHID;
}
*/

View file

@ -1897,6 +1897,11 @@ abstract class LiskDAO {
continue;
}
if ($property === 'spacePHID') {
$map[$property] = 'phid?';
continue;
}
// If the column is named `somethingPHID`, infer it is a PHID.
if (preg_match('/[a-z]PHID$/', $property)) {
$map[$property] = 'phid';
@ -1937,6 +1942,11 @@ abstract class LiskDAO {
'unique' => true,
);
break;
case 'spacePHID':
$default_map['key_space'] = array(
'columns' => array('spacePHID'),
);
break;
}
}