From: Matthias Schmidt Date: Fri, 27 Sep 2019 15:06:11 +0000 (+0200) Subject: Remove support for unsigned database columns in PHP API X-Git-Tag: 5.2.0_Beta_2~29^2~3 X-Git-Url: https://git.stricted.de/?a=commitdiff_plain;h=ef5d8ae60928f42bdbcaf7f27f12e7b07a155736;p=GitHub%2FWoltLab%2FWCF.git Remove support for unsigned database columns in PHP API --- diff --git a/wcfsetup/install/files/lib/system/database/editor/MySQLDatabaseEditor.class.php b/wcfsetup/install/files/lib/system/database/editor/MySQLDatabaseEditor.class.php index 406bbbeedb..80b7e0667b 100644 --- a/wcfsetup/install/files/lib/system/database/editor/MySQLDatabaseEditor.class.php +++ b/wcfsetup/install/files/lib/system/database/editor/MySQLDatabaseEditor.class.php @@ -31,7 +31,7 @@ class MySQLDatabaseEditor extends DatabaseEditor { */ public function getColumns($tableName) { $columns = []; - $regex = new Regex('([a-z]+)\((.+)\)( unsigned)?', Regex::CASE_INSENSITIVE); + $regex = new Regex('([a-z]+)\((.+)\)', Regex::CASE_INSENSITIVE); $sql = "SHOW COLUMNS FROM `".$tableName."`"; $statement = $this->dbObj->prepareStatement($sql); @@ -44,7 +44,6 @@ class MySQLDatabaseEditor extends DatabaseEditor { $length = ''; $decimals = ''; $enumValues = ''; - $unsigned = false; if (!empty($typeMatches)) { $type = $typeMatches[1]; @@ -76,10 +75,6 @@ class MySQLDatabaseEditor extends DatabaseEditor { } break; } - - if (isset($typeMatches[3])) { - $unsigned = true; - } } $columns[] = ['name' => $row['Field'], 'data' => [ @@ -90,8 +85,7 @@ class MySQLDatabaseEditor extends DatabaseEditor { 'default' => $row['Default'], 'autoIncrement' => $row['Extra'] == 'auto_increment' ? true : false, 'enumValues' => $enumValues, - 'decimals' => $decimals, - 'unsigned' => $unsigned + 'decimals' => $decimals ]]; } @@ -373,10 +367,6 @@ class MySQLDatabaseEditor extends DatabaseEditor { // column type $definition .= " ".$columnData['type']; - if (!empty($columnData['unsigned'])) { - $definition .= ' UNSIGNED'; - } - // column length and decimals if (!empty($columnData['length'])) { $definition .= "(".$columnData['length'].(!empty($columnData['decimals']) ? ",".$columnData['decimals'] : "").")"; diff --git a/wcfsetup/install/files/lib/system/database/table/column/AbstractDatabaseTableColumn.class.php b/wcfsetup/install/files/lib/system/database/table/column/AbstractDatabaseTableColumn.class.php index 3952e495af..eb489c9b71 100644 --- a/wcfsetup/install/files/lib/system/database/table/column/AbstractDatabaseTableColumn.class.php +++ b/wcfsetup/install/files/lib/system/database/table/column/AbstractDatabaseTableColumn.class.php @@ -79,10 +79,6 @@ abstract class AbstractDatabaseTableColumn implements IDatabaseTableColumn { $data['length'] = $this->getLength(); } - if ($this instanceof IUnsignedDatabaseTableColumn) { - $data['unsigned'] = $this->isUnsigned(); - } - return $data; } @@ -194,10 +190,6 @@ abstract class AbstractDatabaseTableColumn implements IDatabaseTableColumn { $column->length($data['length'] ?: null); } - if ($column instanceof IUnsignedDatabaseTableColumn) { - $column->unsigned($data['unsigned'] ?? false); - } - return $column; } } diff --git a/wcfsetup/install/files/lib/system/database/table/column/AbstractDecimalDatabaseTableColumn.class.php b/wcfsetup/install/files/lib/system/database/table/column/AbstractDecimalDatabaseTableColumn.class.php index e76adcef80..5ba2b46a4b 100644 --- a/wcfsetup/install/files/lib/system/database/table/column/AbstractDecimalDatabaseTableColumn.class.php +++ b/wcfsetup/install/files/lib/system/database/table/column/AbstractDecimalDatabaseTableColumn.class.php @@ -10,7 +10,6 @@ namespace wcf\system\database\table\column; * @package WoltLabSuite\Core\System\Database\Table\Column * @since 5.2 */ -abstract class AbstractDecimalDatabaseTableColumn extends AbstractDatabaseTableColumn implements IDecimalsDatabaseTableColumn, IUnsignedDatabaseTableColumn { +abstract class AbstractDecimalDatabaseTableColumn extends AbstractDatabaseTableColumn implements IDecimalsDatabaseTableColumn { use TDecimalsDatabaseTableColumn; - use TUnsignedDatabaseTableColumn; } diff --git a/wcfsetup/install/files/lib/system/database/table/column/AbstractIntDatabaseTableColumn.class.php b/wcfsetup/install/files/lib/system/database/table/column/AbstractIntDatabaseTableColumn.class.php index 9e01837392..f0235f3d5b 100644 --- a/wcfsetup/install/files/lib/system/database/table/column/AbstractIntDatabaseTableColumn.class.php +++ b/wcfsetup/install/files/lib/system/database/table/column/AbstractIntDatabaseTableColumn.class.php @@ -10,10 +10,9 @@ namespace wcf\system\database\table\column; * @package WoltLabSuite\Core\System\Database\Table\Column * @since 5.2 */ -abstract class AbstractIntDatabaseTableColumn extends AbstractDatabaseTableColumn implements IAutoIncrementDatabaseTableColumn, ILengthDatabaseTableColumn, IUnsignedDatabaseTableColumn { +abstract class AbstractIntDatabaseTableColumn extends AbstractDatabaseTableColumn implements IAutoIncrementDatabaseTableColumn, ILengthDatabaseTableColumn { use TAutoIncrementDatabaseTableColumn; use TLengthDatabaseTableColumn; - use TUnsignedDatabaseTableColumn; /** * @inheritDoc diff --git a/wcfsetup/install/files/lib/system/database/table/column/BigintDatabaseTableColumn.class.php b/wcfsetup/install/files/lib/system/database/table/column/BigintDatabaseTableColumn.class.php index 0340420fb4..eeba99c7d0 100644 --- a/wcfsetup/install/files/lib/system/database/table/column/BigintDatabaseTableColumn.class.php +++ b/wcfsetup/install/files/lib/system/database/table/column/BigintDatabaseTableColumn.class.php @@ -22,11 +22,4 @@ class BigintDatabaseTableColumn extends AbstractIntDatabaseTableColumn { public function getMaximumLength() { return 20; } - - /** - * @inheritDoc - */ - public function getMaximumUnsignedLength() { - return 19; - } } diff --git a/wcfsetup/install/files/lib/system/database/table/column/IUnsignedDatabaseTableColumn.class.php b/wcfsetup/install/files/lib/system/database/table/column/IUnsignedDatabaseTableColumn.class.php deleted file mode 100644 index b41ae3e3a6..0000000000 --- a/wcfsetup/install/files/lib/system/database/table/column/IUnsignedDatabaseTableColumn.class.php +++ /dev/null @@ -1,28 +0,0 @@ - - * @package WoltLabSuite\Core\System\Database\Table\Column - * @since 5.2 - */ -interface IUnsignedDatabaseTableColumn extends IDatabaseTableColumn { - /** - * Returns `true` if the values of the database table column are unsigned. - * - * @return bool - */ - public function isUnsigned(); - - /** - * Sets if the values of the database table column are unsigned and returns this column. - * - * @param bool $unsigned - * @return $this - */ - public function unsigned($unsigned = true); -} diff --git a/wcfsetup/install/files/lib/system/database/table/column/MediumintDatabaseTableColumn.class.php b/wcfsetup/install/files/lib/system/database/table/column/MediumintDatabaseTableColumn.class.php index 42597780ec..a28027a428 100644 --- a/wcfsetup/install/files/lib/system/database/table/column/MediumintDatabaseTableColumn.class.php +++ b/wcfsetup/install/files/lib/system/database/table/column/MediumintDatabaseTableColumn.class.php @@ -22,11 +22,4 @@ class MediumintDatabaseTableColumn extends AbstractIntDatabaseTableColumn { public function getMaximumLength() { return 8; } - - /** - * @inheritDoc - */ - public function getMaximumUnsignedLength() { - return 7; - } } diff --git a/wcfsetup/install/files/lib/system/database/table/column/TLengthDatabaseTableColumn.class.php b/wcfsetup/install/files/lib/system/database/table/column/TLengthDatabaseTableColumn.class.php index 582a97a5be..eb614fe994 100644 --- a/wcfsetup/install/files/lib/system/database/table/column/TLengthDatabaseTableColumn.class.php +++ b/wcfsetup/install/files/lib/system/database/table/column/TLengthDatabaseTableColumn.class.php @@ -24,20 +24,6 @@ trait TLengthDatabaseTableColumn { * @return null|int */ public function getMaximumLength() { - if ($this instanceof IUnsignedDatabaseTableColumn && $this->getMaximumUnsignedLength() !== null) { - return $this->getMaximumUnsignedLength(); - } - - return null; - } - - /** - * Returns the maximum length value supported by the values of the column are unsigned values - * or `null` if there is no such maximum. - * - * @return null|int - */ - public function getMaximumUnsignedLength() { return null; } diff --git a/wcfsetup/install/files/lib/system/database/table/column/TUnsignedDatabaseTableColumn.class.php b/wcfsetup/install/files/lib/system/database/table/column/TUnsignedDatabaseTableColumn.class.php deleted file mode 100644 index aa6ef31334..0000000000 --- a/wcfsetup/install/files/lib/system/database/table/column/TUnsignedDatabaseTableColumn.class.php +++ /dev/null @@ -1,40 +0,0 @@ - - * @package WoltLabSuite\Core\System\Database\Table\Column - * @since 5.2 - */ -trait TUnsignedDatabaseTableColumn { - /** - * `true` if the values of the database table column are unsigned - * @var bool - */ - protected $unsigned = false; - - /** - * Returns `true` if the values of the database table column are unsigned. - * - * @return bool - */ - public function isUnsigned() { - return $this->unsigned; - } - - /** - * Sets if the values of the database table column are unsigned and returns this column. - * - * @param bool $unsigned - * @return $this - */ - public function unsigned($unsigned = true) { - $this->unsigned = $unsigned; - - return $this; - } -}