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

Generate reasonable expected schemata for Cache tables

Summary:
Ref T1191. Notable:

- Rename `blob` to `bytes` for clarity.
- Introduce raw schema specs.

Test Plan: See screenshots.

Reviewers: btrahan

Reviewed By: btrahan

Subscribers: epriestley

Maniphest Tasks: T1191

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

+78 -7
+2
src/__phutil_library_map__.php
··· 1277 1277 'PhabricatorCacheManagementPurgeWorkflow' => 'applications/cache/management/PhabricatorCacheManagementPurgeWorkflow.php', 1278 1278 'PhabricatorCacheManagementWorkflow' => 'applications/cache/management/PhabricatorCacheManagementWorkflow.php', 1279 1279 'PhabricatorCacheMarkupGarbageCollector' => 'applications/cache/garbagecollector/PhabricatorCacheMarkupGarbageCollector.php', 1280 + 'PhabricatorCacheSchemaSpec' => 'applications/cache/storage/PhabricatorCacheSchemaSpec.php', 1280 1281 'PhabricatorCacheTTLGarbageCollector' => 'applications/cache/garbagecollector/PhabricatorCacheTTLGarbageCollector.php', 1281 1282 'PhabricatorCaches' => 'applications/cache/PhabricatorCaches.php', 1282 1283 'PhabricatorCalendarApplication' => 'applications/calendar/application/PhabricatorCalendarApplication.php', ··· 4161 4162 'PhabricatorCacheManagementPurgeWorkflow' => 'PhabricatorCacheManagementWorkflow', 4162 4163 'PhabricatorCacheManagementWorkflow' => 'PhabricatorManagementWorkflow', 4163 4164 'PhabricatorCacheMarkupGarbageCollector' => 'PhabricatorGarbageCollector', 4165 + 'PhabricatorCacheSchemaSpec' => 'PhabricatorConfigSchemaSpec', 4164 4166 'PhabricatorCacheTTLGarbageCollector' => 'PhabricatorGarbageCollector', 4165 4167 'PhabricatorCalendarApplication' => 'PhabricatorApplication', 4166 4168 'PhabricatorCalendarBrowseController' => 'PhabricatorCalendarController',
+31
src/applications/cache/storage/PhabricatorCacheSchemaSpec.php
··· 1 + <?php 2 + 3 + final class PhabricatorCacheSchemaSpec extends PhabricatorConfigSchemaSpec { 4 + 5 + public function buildSchemata() { 6 + $this->buildLiskSchemata('PhabricatorCacheDAO'); 7 + 8 + $this->buildRawSchema( 9 + 'cache', 10 + id(new PhabricatorKeyValueDatabaseCache())->getTableName(), 11 + array( 12 + 'id' => 'id64', 13 + 'cacheKeyHash' => 'bytes12', 14 + 'cacheKey' => 'text128', 15 + 'cacheFormat' => 'text16', 16 + 'cacheData' => 'bytes', 17 + 'cacheCreated' => 'epoch', 18 + 'cacheExpires' => 'epoch?', 19 + ), 20 + array( 21 + 'PRIMARY' => array( 22 + 'columns' => array('id'), 23 + ), 24 + 'key_cacheKeyHash' => array( 25 + 'columns' => array('cacheKeyHash'), 26 + ), 27 + )); 28 + 29 + } 30 + 31 + }
+8
src/applications/cache/storage/PhabricatorMarkupCache.php
··· 15 15 self::CONFIG_BINARY => array( 16 16 'cacheData' => true, 17 17 ), 18 + self::CONFIG_COLUMN_SCHEMA => array( 19 + 'cacheKey' => 'text128', 20 + ), 21 + self::CONFIG_KEY_SCHEMA => array( 22 + 'cacheKey' => array( 23 + 'columns' => array('cacheKey'), 24 + ), 25 + ), 18 26 ) + parent::getConfiguration(); 19 27 } 20 28
+7
src/applications/config/schema/PhabricatorConfigColumnSchema.php
··· 67 67 return ((int)$matches[1]) * 4; 68 68 } 69 69 70 + $matches = null; 71 + if (preg_match('/^char\((\d+)\)$/', $type, $matches)) { 72 + // We use char() only for fixed-length binary data, so its size 73 + // is always the column size. 74 + return ((int)$matches[1]); 75 + } 76 + 70 77 switch ($type) { 71 78 case 'int(10) unsigned': 72 79 return 4;
+29 -6
src/applications/config/schema/PhabricatorConfigSchemaSpec.php
··· 57 57 } 58 58 59 59 private function buildLiskObjectSchema(PhabricatorLiskDAO $object) { 60 - $database = $this->getDatabase($object->getApplicationName()); 60 + $this->buildRawSchema( 61 + $object->getApplicationName(), 62 + $object->getTableName(), 63 + $object->getSchemaColumns(), 64 + $object->getSchemaKeys()); 65 + } 61 66 62 - $table = $this->newTable($object->getTableName()); 67 + protected function buildRawSchema( 68 + $database_name, 69 + $table_name, 70 + array $columns, 71 + array $keys) { 72 + $database = $this->getDatabase($database_name); 63 73 64 - $cols = $object->getSchemaColumns(); 65 - foreach ($cols as $name => $type) { 74 + $table = $this->newTable($table_name); 75 + 76 + foreach ($columns as $name => $type) { 66 77 $details = $this->getDetailsForDataType($type); 67 78 list($column_type, $charset, $collation, $nullable) = $details; 68 79 ··· 76 87 $table->addColumn($column); 77 88 } 78 89 79 - $keys = $object->getSchemaKeys(); 80 90 foreach ($keys as $key_name => $key_spec) { 81 91 $key = $this->newKey($key_name) 82 92 ->setColumnNames(idx($key_spec, 'columns', array())); ··· 147 157 case 'uint32': 148 158 $column_type = 'int(10) unsigned'; 149 159 break; 160 + case 'id64': 161 + $column_type = 'bigint(20) unsigned'; 162 + break; 150 163 case 'phid': 151 164 case 'policy'; 152 165 $column_type = 'varchar(64)'; 153 166 $charset = 'binary'; 154 167 $collation = 'binary'; 155 168 break; 156 - case 'blob': 169 + case 'bytes12': 170 + $column_type = 'char(12)'; 171 + $charset = 'binary'; 172 + $collation = 'binary'; 173 + break; 174 + case 'bytes': 157 175 $column_type = 'longblob'; 158 176 $charset = 'binary'; 159 177 $collation = 'binary'; ··· 170 188 break; 171 189 case 'text32': 172 190 $column_type = 'varchar(32)'; 191 + $charset = $this->getUTF8Charset(); 192 + $collation = $this->getUTF8Collation(); 193 + break; 194 + case 'text16': 195 + $column_type = 'varchar(16)'; 173 196 $charset = $this->getUTF8Charset(); 174 197 $collation = $this->getUTF8Collation(); 175 198 break;
+1 -1
src/infrastructure/storage/lisk/LiskDAO.php
··· 1734 1734 1735 1735 $serialization_map = array( 1736 1736 self::SERIALIZATION_JSON => 'text', 1737 - self::SERIALIZATION_PHP => 'blob', 1737 + self::SERIALIZATION_PHP => 'bytes', 1738 1738 ); 1739 1739 1740 1740 $builtin = array(