Require length before setting decimals of DecimalDatabaseTableColumn
authorMatthias Schmidt <gravatronics@live.com>
Tue, 4 Feb 2020 17:57:02 +0000 (18:57 +0100)
committerMatthias Schmidt <gravatronics@live.com>
Tue, 4 Feb 2020 17:57:02 +0000 (18:57 +0100)
wcfsetup/install/files/lib/system/database/table/column/AbstractDatabaseTableColumn.class.php
wcfsetup/install/files/lib/system/database/table/column/DecimalDatabaseTableColumn.class.php

index 3c84ac5e7ff0a76f8616e9410dfebd4fa910dded..d712eeeabdf9714604ab4e35e2bbd497ce164f4c 100644 (file)
@@ -176,6 +176,10 @@ abstract class AbstractDatabaseTableColumn implements IDatabaseTableColumn {
                        $column->autoIncrement($data['autoIncrement'] ?: null);
                }
                
+               if ($column instanceof ILengthDatabaseTableColumn) {
+                       $column->length($data['length'] ?: null);
+               }
+               
                if ($column instanceof IDecimalsDatabaseTableColumn) {
                        $column->decimals($data['decimals'] ?: null);
                }
@@ -193,10 +197,6 @@ abstract class AbstractDatabaseTableColumn implements IDatabaseTableColumn {
                        $column->enumValues($values);
                }
                
-               if ($column instanceof ILengthDatabaseTableColumn) {
-                       $column->length($data['length'] ?: null);
-               }
-               
                return $column;
        }
 }
index 6a4f408426b47a095e74a10ab77ceddad7556cda..5195d75a94a76dada4b1b5aea3e66bad20625764 100644 (file)
@@ -16,6 +16,17 @@ class DecimalDatabaseTableColumn extends AbstractDecimalDatabaseTableColumn {
         */
        protected $type = 'decimal';
        
+       /**
+        * @inheritDoc
+        */
+       public function decimals($decimals) {
+               if ($this->getLength() === null) {
+                       throw new \BadMethodCallException("Before setting the decimals, the length has to be set.");
+               }
+               
+               return parent::decimals($decimals);
+       }
+       
        /**
         * @inheritDoc
         */