Check for missing length of varchar columns
authorMatthias Schmidt <gravatronics@live.com>
Wed, 24 Jun 2020 15:21:02 +0000 (17:21 +0200)
committerMatthias Schmidt <gravatronics@live.com>
Wed, 24 Jun 2020 15:21:02 +0000 (17:21 +0200)
wcfsetup/install/files/lib/system/database/table/column/VarcharDatabaseTableColumn.class.php

index 2e18e5ed82ae639dc757ea3257afe6d6f41174e7..db6a8b66df6e34982219541cb0c7ed9b2993c3ae 100644 (file)
@@ -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 <http://opensource.org/licenses/lgpl-license.php>
  * @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
         */