Page Menu
Home
Phabricator
Search
Configure Global Search
Log In
Files
F14004804
D14731.id35631.diff
No One
Temporary
Actions
View File
Edit File
Delete File
View Transforms
Subscribe
Mute Notifications
Award Token
Flag For Later
Size
7 KB
Referenced Files
None
Subscribers
None
D14731.id35631.diff
View Options
diff --git a/resources/sql/autopatches/20151210.land.1.refphid.sql b/resources/sql/autopatches/20151210.land.1.refphid.sql
new file mode 100644
--- /dev/null
+++ b/resources/sql/autopatches/20151210.land.1.refphid.sql
@@ -0,0 +1,2 @@
+ALTER TABLE {$NAMESPACE}_repository.repository_refcursor
+ ADD phid VARBINARY(64) NOT NULL AFTER id;
diff --git a/resources/sql/autopatches/20151210.land.2.refphid.php b/resources/sql/autopatches/20151210.land.2.refphid.php
new file mode 100644
--- /dev/null
+++ b/resources/sql/autopatches/20151210.land.2.refphid.php
@@ -0,0 +1,17 @@
+<?php
+
+$table = new PhabricatorRepositoryRefCursor();
+$conn_w = $table->establishConnection('w');
+
+foreach (new LiskMigrationIterator($table) as $cursor) {
+ if (strlen($cursor->getPHID())) {
+ continue;
+ }
+
+ queryfx(
+ $conn_w,
+ 'UPDATE %T SET phid = %s WHERE id = %d',
+ $table->getTableName(),
+ $table->generatePHID(),
+ $cursor->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
@@ -2907,6 +2907,7 @@
'PhabricatorRepositoryPushReplyHandler' => 'applications/repository/mail/PhabricatorRepositoryPushReplyHandler.php',
'PhabricatorRepositoryQuery' => 'applications/repository/query/PhabricatorRepositoryQuery.php',
'PhabricatorRepositoryRefCursor' => 'applications/repository/storage/PhabricatorRepositoryRefCursor.php',
+ 'PhabricatorRepositoryRefCursorPHIDType' => 'applications/repository/phid/PhabricatorRepositoryRefCursorPHIDType.php',
'PhabricatorRepositoryRefCursorQuery' => 'applications/repository/query/PhabricatorRepositoryRefCursorQuery.php',
'PhabricatorRepositoryRefEngine' => 'applications/repository/engine/PhabricatorRepositoryRefEngine.php',
'PhabricatorRepositoryRepositoryPHIDType' => 'applications/repository/phid/PhabricatorRepositoryRepositoryPHIDType.php',
@@ -7199,6 +7200,7 @@
'PhabricatorRepositoryDAO',
'PhabricatorPolicyInterface',
),
+ 'PhabricatorRepositoryRefCursorPHIDType' => 'PhabricatorPHIDType',
'PhabricatorRepositoryRefCursorQuery' => 'PhabricatorCursorPagedPolicyAwareQuery',
'PhabricatorRepositoryRefEngine' => 'PhabricatorRepositoryEngine',
'PhabricatorRepositoryRepositoryPHIDType' => 'PhabricatorPHIDType',
diff --git a/src/applications/repository/phid/PhabricatorRepositoryRefCursorPHIDType.php b/src/applications/repository/phid/PhabricatorRepositoryRefCursorPHIDType.php
new file mode 100644
--- /dev/null
+++ b/src/applications/repository/phid/PhabricatorRepositoryRefCursorPHIDType.php
@@ -0,0 +1,42 @@
+<?php
+
+final class PhabricatorRepositoryRefCursorPHIDType
+ extends PhabricatorPHIDType {
+
+ const TYPECONST = 'RREF';
+
+ public function getTypeName() {
+ return pht('Repository Ref');
+ }
+
+ public function newObject() {
+ return new PhabricatorRepositoryRefCursor();
+ }
+
+ public function getPHIDTypeApplicationClass() {
+ return 'PhabricatorDiffusionApplication';
+ }
+
+ protected function buildQueryForObjects(
+ PhabricatorObjectQuery $query,
+ array $phids) {
+
+ return id(new PhabricatorRepositoryRefCursorQuery())
+ ->withPHIDs($phids);
+ }
+
+ public function loadHandles(
+ PhabricatorHandleQuery $query,
+ array $handles,
+ array $objects) {
+
+ foreach ($handles as $phid => $handle) {
+ $ref = $objects[$phid];
+
+ $name = $ref->getRefName();
+
+ $handle->setName($name);
+ }
+ }
+
+}
diff --git a/src/applications/repository/query/PhabricatorRepositoryRefCursorQuery.php b/src/applications/repository/query/PhabricatorRepositoryRefCursorQuery.php
--- a/src/applications/repository/query/PhabricatorRepositoryRefCursorQuery.php
+++ b/src/applications/repository/query/PhabricatorRepositoryRefCursorQuery.php
@@ -3,10 +3,22 @@
final class PhabricatorRepositoryRefCursorQuery
extends PhabricatorCursorPagedPolicyAwareQuery {
+ private $ids;
+ private $phids;
private $repositoryPHIDs;
private $refTypes;
private $refNames;
+ public function withIDs(array $ids) {
+ $this->ids = $ids;
+ return $this;
+ }
+
+ public function withPHIDs(array $phids) {
+ $this->phids = $phids;
+ return $this;
+ }
+
public function withRepositoryPHIDs(array $phids) {
$this->repositoryPHIDs = $phids;
return $this;
@@ -22,19 +34,12 @@
return $this;
}
+ public function newResultObject() {
+ return new PhabricatorRepositoryRefCursor();
+ }
+
protected function loadPage() {
- $table = new PhabricatorRepositoryRefCursor();
- $conn_r = $table->establishConnection('r');
-
- $data = queryfx_all(
- $conn_r,
- 'SELECT * FROM %T r %Q %Q %Q',
- $table->getTableName(),
- $this->buildWhereClause($conn_r),
- $this->buildOrderClause($conn_r),
- $this->buildLimitClause($conn_r));
-
- return $table->loadAllFromArray($data);
+ return $this->loadStandardPage($this->newResultObject());
}
protected function willFilterPage(array $refs) {
@@ -50,6 +55,7 @@
foreach ($refs as $key => $ref) {
$repository = idx($repositories, $ref->getRepositoryPHID());
if (!$repository) {
+ $this->didRejectResult($ref);
unset($refs[$key]);
continue;
}
@@ -59,19 +65,33 @@
return $refs;
}
- protected function buildWhereClause(AphrontDatabaseConnection $conn_r) {
- $where = array();
+ 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);
+ }
if ($this->repositoryPHIDs !== null) {
$where[] = qsprintf(
- $conn_r,
+ $conn,
'repositoryPHID IN (%Ls)',
$this->repositoryPHIDs);
}
if ($this->refTypes !== null) {
$where[] = qsprintf(
- $conn_r,
+ $conn,
'refType IN (%Ls)',
$this->refTypes);
}
@@ -83,14 +103,12 @@
}
$where[] = qsprintf(
- $conn_r,
+ $conn,
'refNameHash IN (%Ls)',
$name_hashes);
}
- $where[] = $this->buildPagingClause($conn_r);
-
- return $this->formatWhereClause($where);
+ return $where;
}
public function getQueryApplicationClass() {
diff --git a/src/applications/repository/storage/PhabricatorRepositoryRefCursor.php b/src/applications/repository/storage/PhabricatorRepositoryRefCursor.php
--- a/src/applications/repository/storage/PhabricatorRepositoryRefCursor.php
+++ b/src/applications/repository/storage/PhabricatorRepositoryRefCursor.php
@@ -5,7 +5,8 @@
* out how a repository has changed when we discover new commits or branch
* heads.
*/
-final class PhabricatorRepositoryRefCursor extends PhabricatorRepositoryDAO
+final class PhabricatorRepositoryRefCursor
+ extends PhabricatorRepositoryDAO
implements PhabricatorPolicyInterface {
const TYPE_BRANCH = 'branch';
@@ -25,6 +26,7 @@
protected function getConfiguration() {
return array(
self::CONFIG_TIMESTAMPS => false,
+ self::CONFIG_AUX_PHID => true,
self::CONFIG_BINARY => array(
'refNameRaw' => true,
),
@@ -32,9 +34,6 @@
'refType' => 'text32',
'refNameHash' => 'bytes12',
'commitIdentifier' => 'text40',
-
- // T6203/NULLABILITY
- // This probably should not be nullable; refNameRaw is not nullable.
'refNameEncoding' => 'text16?',
'isClosed' => 'bool',
),
@@ -46,6 +45,11 @@
) + parent::getConfiguration();
}
+ public function generatePHID() {
+ return PhabricatorPHID::generateNewPHID(
+ PhabricatorRepositoryRefCursorPHIDType::TYPECONST);
+ }
+
public function getRefName() {
return $this->getUTF8StringFromStorage(
$this->getRefNameRaw(),
File Metadata
Details
Attached
Mime Type
text/plain
Expires
Mon, Oct 28, 2:52 AM (3 w, 2 h ago)
Storage Engine
blob
Storage Format
Encrypted (AES-256-CBC)
Storage Handle
6725620
Default Alt Text
D14731.id35631.diff (7 KB)
Attached To
Mode
D14731: Add proper PHIDs to RefCursors
Attached
Detach File
Event Timeline
Log In to Comment