From 82a3a227af1b669a8d427575e31f989764c8c4f7 Mon Sep 17 00:00:00 2001 From: Matthias Schmidt Date: Wed, 24 Jun 2020 17:21:02 +0200 Subject: [PATCH] Check for missing length of varchar columns --- .../VarcharDatabaseTableColumn.class.php | 19 ++++++++++++++++--- 1 file changed, 16 insertions(+), 3 deletions(-) diff --git a/wcfsetup/install/files/lib/system/database/table/column/VarcharDatabaseTableColumn.class.php b/wcfsetup/install/files/lib/system/database/table/column/VarcharDatabaseTableColumn.class.php index 2e18e5ed82..db6a8b66df 100644 --- a/wcfsetup/install/files/lib/system/database/table/column/VarcharDatabaseTableColumn.class.php +++ b/wcfsetup/install/files/lib/system/database/table/column/VarcharDatabaseTableColumn.class.php @@ -3,21 +3,34 @@ namespace wcf\system\database\table\column; /** * Represents a `varchar` database table column. - * + * * @author Matthias Schmidt - * @copyright 2001-2019 WoltLab GmbH + * @copyright 2001-2020 WoltLab GmbH * @license GNU Lesser General Public License * @package WoltLabSuite\Core\System\Database\Table\Column * @since 5.2 */ class VarcharDatabaseTableColumn extends AbstractDatabaseTableColumn implements ILengthDatabaseTableColumn { - use TLengthDatabaseTableColumn; + use TLengthDatabaseTableColumn { + getLength as protected traitGetLength; + } /** * @inheritDoc */ protected $type = 'varchar'; + /** + * @inheritDoc + */ + public function getLength() { + if ($this->length === null) { + throw new \LogicException('The length of varchar fields must be explicitly set.'); + } + + return $this->traitGetLength(); + } + /** * @inheritDoc */ -- 2.20.1