Contao: DcaSchemaProvider->parseColumnSql explodes null

Created on 9 Oct 2019  路  3Comments  路  Source: contao/contao

Affected version(s)
4.8.4

Description
I updated a Contao 4.4 to 4.8.4 and then I got some trouble in the installer.
Unfortunately, I just found the error after some debugging because the log won't tell you the reason.
In a custom DCA we had some legacy sql definition (the value was "INTEGER" - without any whitespaces).

Finally I found the reason, that $def can be null, if the string $sql contains no whitespace here:
https://github.com/contao/contao/blob/2635f5a043c1308fd3fe1352b4b9de7665206cc8/core-bundle/src/Doctrine/Schema/DcaSchemaProvider.php#L157

Afterwards you will get an exception, because preg_match won't accept the given null of $def
https://github.com/contao/contao/blob/2635f5a043c1308fd3fe1352b4b9de7665206cc8/core-bundle/src/Doctrine/Schema/DcaSchemaProvider.php#L176

How to reproduce
Set the following definition in a DCA for any field:

'sql' => "INTEGER"

In the meantime I replaced the value in the DCA to: int(11) DEFAULT NULL, which fixed of course the problem for me :-)

I guess there should be a explaining exception if $def is null.

bug

Most helpful comment

Or we simply accept without a space as well? If that worked before, it should still work now?

All 3 comments

I guess there should be a explaining exception if $def is null.

Agreed. 馃槂

Or we simply accept without a space as well? If that worked before, it should still work now?

Fixed in 6e8e97568f58843f6eb2026d9a465671c308625e.

Was this page helpful?
0 / 5 - 0 ratings

Related issues

Mynyx picture Mynyx  路  3Comments

leofeyer picture leofeyer  路  3Comments

fritzmg picture fritzmg  路  3Comments

issue-bot picture issue-bot  路  4Comments

mathContao picture mathContao  路  3Comments