Issue Bug Closed

#105356Type error in Doctrine Schema\Column::setLength argument 1 must be int

Franz Holzinger 10/18/24, 16:08 updated 12/02/25, 14:32

Description

After the activation of an extension I get this error messsage in the backend:

Doctrine\DBAL\Schema\Column::setLength(): Argument #1 ($length) must be of type ?int, string given, called in /path/typo3_src-13.4.0/vendor/doctrine/dbal/src/Schema/Column.php on line 68

Called from TCA:

at Doctrine\DBAL\Schema\Column->setLength('10')
in /path/typo3_src-13.4.0/vendor/doctrine/dbal/src/Schema/Column.php line 68
            if (! method_exists($this, $method)) {
                throw UnknownColumnOption::new($name);
            }

            $this->$method($value);
        }

        return $this;
    }
at Doctrine\DBAL\Schema\Column->setOptions(array('length' => '10', 'default' => '', 'notnull' => true))
in /path/typo3_src-13.4.0/vendor/doctrine/dbal/src/Schema/Column.php line 55
    public function __construct(string $name, Type $type, array $options = [])
    {
        $this->_setName($name);
        $this->setType($type);
        $this->setOptions($options);
    }

    /** @param array<string, mixed> $options */
    public function setOptions(array $options): self
at Doctrine\DBAL\Schema\Column->__construct('`creditpoints_gifts`', object(Doctrine\DBAL\Types\StringType), array('length' => '10', 'default' => '', 'notnull' => true))
in /path/typo3_src-13.4.0/vendor/doctrine/dbal/src/Schema/Table.php line 266

    /** @param array<string, mixed> $options */
    public function addColumn(string $name, string $typeName, array $options = []): Column
    {
        $column = new Column($name, Type::getType($typeName), $options);

        $this->_addColumn($column);

        return $column;
at Doctrine\DBAL\Schema\Table->addColumn('`creditpoints_gifts`', 'string', array('length' => '10', 'default' => '', 'notnull' => true))
in /path/typo3_src-13.4.0/typo3/sysext/core/Classes/Database/Schema/DefaultTcaSchema.php line 785
            ]
        );
        break;
    }
    $tables[$tableName]->addColumn(
        $this->quote($fieldName),
        Types::STRING,
        [
            'length' => $length,

Reviews 2

History 610

  1. Garvin Hicking changed category 10/18/24, 16:59

  2. Garvin Hicking commented and changed status New Needs Feedback 10/18/24, 17:00

    Please check your TCA for your “creditpoints_gift” definition. Set “length” to 10 instead of “10”.

  3. Franz Holzinger commented 10/18/24, 18:15

    This change magically fixes this issue.

    tt_products sys_products_orders TCA Modification

  4. Garvin Hicking commented 10/18/24, 18:35

    We can look into applying (int) typecasting at the appropriate places to make this a bit more “casual”. Will address this in the next days and see what the others say about more relaxed TCA definition here.

    (Note though that the type-safer way would be to use integers for numbers here, of course)

  5. Gerrit Code Review pushed patch set 1 for main to change 86661 status Needs Feedback Under Review 10/19/24, 20:37

  6. Gerrit Code Review pushed patch set 2 for main to change 86661 10/22/24, 16:24

  7. Gerrit Code Review pushed patch set 3 for main to change 86661 10/22/24, 17:04

  8. Gerrit Code Review pushed patch set 1 for 13.4 to change 86630 10/23/24, 06:14

  9. Garvin Hicking commented and changed status Under Review Resolved done 0 % 100 % 10/23/24, 06:30

    Applied in changeset commit:3db508c687ff053c50ec5a86355577254d0df934.

  10. Benni Mack changed status Resolved Closed 12/02/25, 14:32