Changeset View
Changeset View
Standalone View
Standalone View
src/applications/config/schema/PhabricatorConfigColumnSchema.php
Show First 20 Lines • Show All 62 Lines • ▼ Show 20 Lines | public function setCharacterSet($character_set) { | ||||
$this->characterSet = $character_set; | $this->characterSet = $character_set; | ||||
return $this; | return $this; | ||||
} | } | ||||
public function getCharacterSet() { | public function getCharacterSet() { | ||||
return $this->characterSet; | return $this->characterSet; | ||||
} | } | ||||
public function hasSameColumnTypeAs(PhabricatorConfigColumnSchema $other) { | |||||
$u_type = $this->getColumnType(); | |||||
$v_type = $other->getColumnType(); | |||||
if ($u_type === $v_type) { | |||||
return true; | |||||
} | |||||
// See T13536. Display widths for integers were deprecated in MySQL 8.0.17 | |||||
// and removed from some display contexts in or around 8.0.19. Older | |||||
// MySQL versions will report "int(10)"; newer versions will report "int". | |||||
// Accept these as equivalent. | |||||
static $map = array( | |||||
'int(10) unsigned' => 'int unsigned', | |||||
'int(10)' => 'int', | |||||
'bigint(20) unsigned' => 'bigint unsigned', | |||||
'bigint(20)' => 'bigint', | |||||
); | |||||
if (isset($map[$u_type])) { | |||||
$u_type = $map[$u_type]; | |||||
} | |||||
if (isset($map[$v_type])) { | |||||
$v_type = $map[$v_type]; | |||||
} | |||||
return ($u_type === $v_type); | |||||
} | |||||
public function getKeyByteLength($prefix = null) { | public function getKeyByteLength($prefix = null) { | ||||
$type = $this->getColumnType(); | $type = $this->getColumnType(); | ||||
$matches = null; | $matches = null; | ||||
if (preg_match('/^(?:var)?char\((\d+)\)$/', $type, $matches)) { | if (preg_match('/^(?:var)?char\((\d+)\)$/', $type, $matches)) { | ||||
// For utf8mb4, each character requires 4 bytes. | // For utf8mb4, each character requires 4 bytes. | ||||
$size = (int)$matches[1]; | $size = (int)$matches[1]; | ||||
if ($prefix && $prefix < $size) { | if ($prefix && $prefix < $size) { | ||||
▲ Show 20 Lines • Show All 54 Lines • ▼ Show 20 Lines | if ($expect->getColumnType() == $type_unknown) { | ||||
if ($this->getCharacterSet() != $expect->getCharacterSet()) { | if ($this->getCharacterSet() != $expect->getCharacterSet()) { | ||||
$issues[] = self::ISSUE_CHARSET; | $issues[] = self::ISSUE_CHARSET; | ||||
} | } | ||||
if ($this->getCollation() != $expect->getCollation()) { | if ($this->getCollation() != $expect->getCollation()) { | ||||
$issues[] = self::ISSUE_COLLATION; | $issues[] = self::ISSUE_COLLATION; | ||||
} | } | ||||
if ($this->getColumnType() != $expect->getColumnType()) { | if (!$this->hasSameColumnTypeAs($expect)) { | ||||
$issues[] = self::ISSUE_COLUMNTYPE; | $issues[] = self::ISSUE_COLUMNTYPE; | ||||
} | } | ||||
if ($this->getNullable() !== $expect->getNullable()) { | if ($this->getNullable() !== $expect->getNullable()) { | ||||
$issues[] = self::ISSUE_NULLABLE; | $issues[] = self::ISSUE_NULLABLE; | ||||
} | } | ||||
if ($this->getAutoIncrement() !== $expect->getAutoIncrement()) { | if ($this->getAutoIncrement() !== $expect->getAutoIncrement()) { | ||||
Show All 13 Lines |