Path: blob/master/src/applications/config/schema/PhabricatorConfigKeySchema.php
12256 views
<?php12final class PhabricatorConfigKeySchema3extends PhabricatorConfigStorageSchema {45const MAX_INNODB_KEY_LENGTH = 767;67private $columnNames;8private $unique;9private $table;10private $indexType;11private $property;1213public function setIndexType($index_type) {14$this->indexType = $index_type;15return $this;16}1718public function getIndexType() {19return $this->indexType;20}2122public function setProperty($property) {23$this->property = $property;24return $this;25}2627public function getProperty() {28return $this->property;29}3031public function setUnique($unique) {32$this->unique = $unique;33return $this;34}3536public function getUnique() {37return $this->unique;38}3940public function setTable(PhabricatorConfigTableSchema $table) {41$this->table = $table;42return $this;43}4445public function getTable() {46return $this->table;47}4849public function setColumnNames(array $column_names) {50$this->columnNames = array_values($column_names);51return $this;52}5354public function getColumnNames() {55return $this->columnNames;56}5758protected function getSubschemata() {59return array();60}6162public function getKeyColumnAndPrefix($column_name) {63$matches = null;64if (preg_match('/^(.*)\((\d+)\)\z/', $column_name, $matches)) {65return array($matches[1], (int)$matches[2]);66} else {67return array($column_name, null);68}69}7071public function getKeyByteLength() {72$size = 0;73foreach ($this->getColumnNames() as $column_spec) {74list($column_name, $prefix) = $this->getKeyColumnAndPrefix($column_spec);75$column = $this->getTable()->getColumn($column_name);76if (!$column) {77$size = 0;78break;79}80$size += $column->getKeyByteLength($prefix);81}8283return $size;84}8586protected function compareToSimilarSchema(87PhabricatorConfigStorageSchema $expect) {8889$issues = array();90if ($this->getColumnNames() !== $expect->getColumnNames()) {91$issues[] = self::ISSUE_KEYCOLUMNS;92}9394if ($this->getUnique() !== $expect->getUnique()) {95$issues[] = self::ISSUE_UNIQUE;96}9798// A fulltext index can be of any length.99if ($this->getIndexType() != 'FULLTEXT') {100if ($this->getKeyByteLength() > self::MAX_INNODB_KEY_LENGTH) {101$issues[] = self::ISSUE_LONGKEY;102}103}104105return $issues;106}107108public function newEmptyClone() {109$clone = clone $this;110$this->table = null;111return $clone;112}113114}115116117