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

at recaptime-dev/main 115 lines 2.5 kB view raw
1<?php 2 3final class PhabricatorConfigKeySchema 4 extends PhabricatorConfigStorageSchema { 5 6 const MAX_INNODB_KEY_LENGTH = 767; 7 8 private $columnNames; 9 private $unique; 10 private $table; 11 private $indexType; 12 private $property; 13 14 public function setIndexType($index_type) { 15 $this->indexType = $index_type; 16 return $this; 17 } 18 19 public function getIndexType() { 20 return $this->indexType; 21 } 22 23 public function setProperty($property) { 24 $this->property = $property; 25 return $this; 26 } 27 28 public function getProperty() { 29 return $this->property; 30 } 31 32 public function setUnique($unique) { 33 $this->unique = $unique; 34 return $this; 35 } 36 37 public function getUnique() { 38 return $this->unique; 39 } 40 41 public function setTable(PhabricatorConfigTableSchema $table) { 42 $this->table = $table; 43 return $this; 44 } 45 46 public function getTable() { 47 return $this->table; 48 } 49 50 public function setColumnNames(array $column_names) { 51 $this->columnNames = array_values($column_names); 52 return $this; 53 } 54 55 public function getColumnNames() { 56 return $this->columnNames; 57 } 58 59 protected function getSubschemata() { 60 return array(); 61 } 62 63 public function getKeyColumnAndPrefix($column_name) { 64 $matches = null; 65 if (preg_match('/^(.*)\((\d+)\)\z/', $column_name, $matches)) { 66 return array($matches[1], (int)$matches[2]); 67 } else { 68 return array($column_name, null); 69 } 70 } 71 72 public function getKeyByteLength() { 73 $size = 0; 74 foreach ($this->getColumnNames() as $column_spec) { 75 list($column_name, $prefix) = $this->getKeyColumnAndPrefix($column_spec); 76 $column = $this->getTable()->getColumn($column_name); 77 if (!$column) { 78 $size = 0; 79 break; 80 } 81 $size += $column->getKeyByteLength($prefix); 82 } 83 84 return $size; 85 } 86 87 protected function compareToSimilarSchema( 88 PhabricatorConfigStorageSchema $expect) { 89 90 $issues = array(); 91 if ($this->getColumnNames() !== $expect->getColumnNames()) { 92 $issues[] = self::ISSUE_KEYCOLUMNS; 93 } 94 95 if ($this->getUnique() !== $expect->getUnique()) { 96 $issues[] = self::ISSUE_UNIQUE; 97 } 98 99 // A fulltext index can be of any length. 100 if ($this->getIndexType() != 'FULLTEXT') { 101 if ($this->getKeyByteLength() > self::MAX_INNODB_KEY_LENGTH) { 102 $issues[] = self::ISSUE_LONGKEY; 103 } 104 } 105 106 return $issues; 107 } 108 109 public function newEmptyClone() { 110 $clone = clone $this; 111 $this->table = null; 112 return $clone; 113 } 114 115}