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

Begin building out RepositoryIdentity indirection layer

Summary: Ref T12164. Start building initial objects for managing `RepositoryIdentity` objects. This won't land until much more of the infrastructure is in place.

Test Plan: Ran `bin/storage upgrade` and observed expected table.

Reviewers: epriestley

Reviewed By: epriestley

Subscribers: Korvin, PHID-OPKG-gm6ozazyms6q6i22gyam

Maniphest Tasks: T12164

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

+162
+14
resources/sql/autopatches/20180430.repo_identity.sql
··· 1 + CREATE TABLE {$NAMESPACE}_repository.repository_identity ( 2 + id INT UNSIGNED NOT NULL AUTO_INCREMENT PRIMARY KEY, 3 + phid VARBINARY(64) NOT NULL, 4 + dateCreated INT UNSIGNED NOT NULL, 5 + dateModified INT UNSIGNED NOT NULL, 6 + automaticGuessedUserPHID VARBINARY(64) DEFAULT NULL, 7 + manuallySetUserPHID VARBINARY(64) DEFAULT NULL, 8 + currentEffectiveUserPHID VARBINARY(64) DEFAULT NULL, 9 + identityNameHash BINARY(12) NOT NULL, 10 + identityNameRaw LONGBLOB NOT NULL, 11 + identityNameEncoding VARCHAR(16) DEFAULT NULL COLLATE {$COLLATE_TEXT}, 12 + UNIQUE KEY `key_phid` (phid), 13 + UNIQUE KEY `key_identity` (identityNameHash) 14 + ) ENGINE=InnoDB DEFAULT CHARSET={$CHARSET} COLLATE={$COLLATE_TEXT};
+6
src/__phutil_library_map__.php
··· 4085 4085 'PhabricatorRepositoryGitLFSRefQuery' => 'applications/repository/query/PhabricatorRepositoryGitLFSRefQuery.php', 4086 4086 'PhabricatorRepositoryGraphCache' => 'applications/repository/graphcache/PhabricatorRepositoryGraphCache.php', 4087 4087 'PhabricatorRepositoryGraphStream' => 'applications/repository/daemon/PhabricatorRepositoryGraphStream.php', 4088 + 'PhabricatorRepositoryIdentity' => 'applications/repository/storage/PhabricatorRepositoryIdentity.php', 4089 + 'PhabricatorRepositoryIdentityPHIDType' => 'applications/repository/phid/PhabricatorRepositoryIdentityPHIDType.php', 4090 + 'PhabricatorRepositoryIdentityQuery' => 'applications/repository/query/PhabricatorRepositoryIdentityQuery.php', 4088 4091 'PhabricatorRepositoryManagementCacheWorkflow' => 'applications/repository/management/PhabricatorRepositoryManagementCacheWorkflow.php', 4089 4092 'PhabricatorRepositoryManagementClusterizeWorkflow' => 'applications/repository/management/PhabricatorRepositoryManagementClusterizeWorkflow.php', 4090 4093 'PhabricatorRepositoryManagementDiscoverWorkflow' => 'applications/repository/management/PhabricatorRepositoryManagementDiscoverWorkflow.php', ··· 9975 9978 'PhabricatorRepositoryGitLFSRefQuery' => 'PhabricatorCursorPagedPolicyAwareQuery', 9976 9979 'PhabricatorRepositoryGraphCache' => 'Phobject', 9977 9980 'PhabricatorRepositoryGraphStream' => 'Phobject', 9981 + 'PhabricatorRepositoryIdentity' => 'PhabricatorRepositoryDAO', 9982 + 'PhabricatorRepositoryIdentityPHIDType' => 'PhabricatorPHIDType', 9983 + 'PhabricatorRepositoryIdentityQuery' => 'PhabricatorCursorPagedPolicyAwareQuery', 9978 9984 'PhabricatorRepositoryManagementCacheWorkflow' => 'PhabricatorRepositoryManagementWorkflow', 9979 9985 'PhabricatorRepositoryManagementClusterizeWorkflow' => 'PhabricatorRepositoryManagementWorkflow', 9980 9986 'PhabricatorRepositoryManagementDiscoverWorkflow' => 'PhabricatorRepositoryManagementWorkflow',
+33
src/applications/repository/phid/PhabricatorRepositoryIdentityPHIDType.php
··· 1 + <?php 2 + 3 + final class PhabricatorRepositoryIdentityPHIDType 4 + extends PhabricatorPHIDType { 5 + 6 + const TYPECONST = 'RIDT'; 7 + 8 + public function getTypeName() { 9 + return pht('Repository Identity'); 10 + } 11 + 12 + public function newObject() { 13 + return new PhabricatorRepositoryIdentity(); 14 + } 15 + 16 + public function getPHIDTypeApplicationClass() { 17 + return 'PhabricatorDiffusionApplication'; 18 + } 19 + 20 + protected function buildQueryForObjects( 21 + PhabricatorObjectQuery $query, 22 + array $phids) { 23 + 24 + return id(new PhabricatorRepositoryIdentityQuery()) 25 + ->withPHIDs($phids); 26 + } 27 + 28 + public function loadHandles( 29 + PhabricatorHandleQuery $query, 30 + array $handles, 31 + array $objects) {} 32 + 33 + }
+69
src/applications/repository/query/PhabricatorRepositoryIdentityQuery.php
··· 1 + <?php 2 + 3 + final class PhabricatorRepositoryIdentityQuery 4 + extends PhabricatorCursorPagedPolicyAwareQuery { 5 + 6 + private $ids; 7 + private $phids; 8 + private $identityNames; 9 + 10 + public function withIDs(array $ids) { 11 + $this->ids = $ids; 12 + return $this; 13 + } 14 + 15 + public function withPHIDs(array $phids) { 16 + $this->phids = $phids; 17 + return $this; 18 + } 19 + 20 + public function withIdentityNames(array $names) { 21 + $this->identityNames = $names; 22 + return $this; 23 + } 24 + 25 + public function newResultObject() { 26 + return new PhabricatorRepositoryIdentity(); 27 + } 28 + 29 + protected function loadPage() { 30 + return $this->loadStandardPage($this->newResultObject()); 31 + } 32 + 33 + protected function buildWhereClauseParts(AphrontDatabaseConnection $conn) { 34 + $where = parent::buildWhereClauseParts($conn); 35 + 36 + if ($this->ids !== null) { 37 + $where[] = qsprintf( 38 + $conn, 39 + 'id IN (%Ld)', 40 + $this->ids); 41 + } 42 + 43 + if ($this->phids !== null) { 44 + $where[] = qsprintf( 45 + $conn, 46 + 'phid IN (%Ls)', 47 + $this->phids); 48 + } 49 + 50 + if ($this->identityNames !== null) { 51 + $name_hashes = array(); 52 + foreach ($this->identityNames as $name) { 53 + $name_hashes[] = PhabricatorHash::digestForIndex($name); 54 + } 55 + 56 + $where[] = qsprintf( 57 + $conn, 58 + 'identityNameHash IN (%Ls)', 59 + $name_hashes); 60 + } 61 + 62 + return $where; 63 + } 64 + 65 + public function getQueryApplicationClass() { 66 + return 'PhabricatorDiffusionApplication'; 67 + } 68 + 69 + }
+40
src/applications/repository/storage/PhabricatorRepositoryIdentity.php
··· 1 + <?php 2 + 3 + final class PhabricatorRepositoryIdentity 4 + extends PhabricatorRepositoryDAO { 5 + 6 + protected $identityNameHash; 7 + protected $identityNameRaw; 8 + protected $identityNameEncoding; 9 + 10 + protected $automaticGuessedUserPHID; 11 + protected $manuallySetUserPHID; 12 + protected $currentEffectiveUserPHID; 13 + 14 + protected function getConfiguration() { 15 + return array( 16 + self::CONFIG_AUX_PHID => true, 17 + self::CONFIG_BINARY => array( 18 + 'identityNameRaw' => true, 19 + ), 20 + self::CONFIG_COLUMN_SCHEMA => array( 21 + 'identityNameHash' => 'bytes12', 22 + 'identityNameEncoding' => 'text16?', 23 + 'automaticGuessedUserPHID' => 'phid?', 24 + 'manuallySetUserPHID' => 'phid?', 25 + 'currentEffectiveUserPHID' => 'phid?', 26 + ), 27 + self::CONFIG_KEY_SCHEMA => array( 28 + 'key_identity' => array( 29 + 'columns' => array('identityNameHash'), 30 + 'unique' => true, 31 + ), 32 + ), 33 + ) + parent::getConfiguration(); 34 + } 35 + 36 + public function getPHIDType() { 37 + return PhabricatorRepositoryIdentityPHIDType::TYPECONST; 38 + } 39 + 40 + }