Remove support for unsigned database columns in PHP API
authorMatthias Schmidt <gravatronics@live.com>
Fri, 27 Sep 2019 15:06:11 +0000 (17:06 +0200)
committerMatthias Schmidt <gravatronics@live.com>
Fri, 27 Sep 2019 15:06:11 +0000 (17:06 +0200)
wcfsetup/install/files/lib/system/database/editor/MySQLDatabaseEditor.class.php
wcfsetup/install/files/lib/system/database/table/column/AbstractDatabaseTableColumn.class.php
wcfsetup/install/files/lib/system/database/table/column/AbstractDecimalDatabaseTableColumn.class.php
wcfsetup/install/files/lib/system/database/table/column/AbstractIntDatabaseTableColumn.class.php
wcfsetup/install/files/lib/system/database/table/column/BigintDatabaseTableColumn.class.php
wcfsetup/install/files/lib/system/database/table/column/IUnsignedDatabaseTableColumn.class.php [deleted file]
wcfsetup/install/files/lib/system/database/table/column/MediumintDatabaseTableColumn.class.php
wcfsetup/install/files/lib/system/database/table/column/TLengthDatabaseTableColumn.class.php
wcfsetup/install/files/lib/system/database/table/column/TUnsignedDatabaseTableColumn.class.php [deleted file]

index 406bbbeedb02af049f291e35221c1559157e936e..80b7e0667b476ab3f8fddf765ab668047540f310 100644 (file)
@@ -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'] : "").")";
index 3952e495afde33d96b43a08311925bc18e239e81..eb489c9b712b504364f15032df054af1cb524e97 100644 (file)
@@ -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;
        }
 }
index e76adcef80f28497dc7632b6bf7b9e353b4a416d..5ba2b46a4bcbdc343bf3f09bc3c0c8933c871c9a 100644 (file)
@@ -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;
 }
index 9e01837392fb02c964d1da1106b395d6b933a64d..f0235f3d5bc702c8b20eff63049e40155bf0faaa 100644 (file)
@@ -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
index 0340420fb4986c485efd2eeae8ae6b11403d8a85..eeba99c7d0214df0dc7acfac9de53dfecf59b6de 100644 (file)
@@ -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 (file)
index b41ae3e..0000000
+++ /dev/null
@@ -1,28 +0,0 @@
-<?php
-namespace wcf\system\database\table\column;
-
-/**
- * Every database table column whose values can be unsigned must implement this interface.
- * 
- * @author     Matthias Schmidt
- * @copyright  2001-2019 WoltLab GmbH
- * @license    GNU Lesser General Public License <http://opensource.org/licenses/lgpl-license.php>
- * @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);
-}
index 42597780ecec0c44770e6cf074e8c45c6f6102ef..a28027a4286293309c6df41a4273edfa3ceacbf8 100644 (file)
@@ -22,11 +22,4 @@ class MediumintDatabaseTableColumn extends AbstractIntDatabaseTableColumn {
        public function getMaximumLength() {
                return 8;
        }
-       
-       /**
-        * @inheritDoc
-        */
-       public function getMaximumUnsignedLength() {
-               return 7;
-       }
 }
index 582a97a5be7333a84466941b4e1784d9463cd019..eb614fe994e44410645b72b2459637ef6d642423 100644 (file)
@@ -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 (file)
index aa6ef31..0000000
+++ /dev/null
@@ -1,40 +0,0 @@
-<?php
-namespace wcf\system\database\table\column;
-
-/**
- * Provides default implementation of the methods of `IUnsignedDatabaseTableColumn`.
- * 
- * @author     Matthias Schmidt
- * @copyright  2001-2019 WoltLab GmbH
- * @license    GNU Lesser General Public License <http://opensource.org/licenses/lgpl-license.php>
- * @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;
-       }
-}