From: Matthias Schmidt Date: Tue, 4 Feb 2020 17:57:02 +0000 (+0100) Subject: Require length before setting decimals of DecimalDatabaseTableColumn X-Git-Tag: 5.2.2~8 X-Git-Url: https://git.stricted.de/?a=commitdiff_plain;h=e261f1ed9b369011fbc747b9bbed66d871f52c52;p=GitHub%2FWoltLab%2FWCF.git Require length before setting decimals of DecimalDatabaseTableColumn --- 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 3c84ac5e7f..d712eeeabd 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 @@ -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; } } diff --git a/wcfsetup/install/files/lib/system/database/table/column/DecimalDatabaseTableColumn.class.php b/wcfsetup/install/files/lib/system/database/table/column/DecimalDatabaseTableColumn.class.php index 6a4f408426..5195d75a94 100644 --- a/wcfsetup/install/files/lib/system/database/table/column/DecimalDatabaseTableColumn.class.php +++ b/wcfsetup/install/files/lib/system/database/table/column/DecimalDatabaseTableColumn.class.php @@ -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 */