Bug #82245
closedInstalling a plugin failes to create table if a field is named 'alter'
100%
Description
Hello,
If a plugin contains a create table statement in ext_tables.sql, in which a field is named 'alter' (german for "age"), Typo3 silently failes to create that table.
Steps to reproduce:
1) Put below (or a similar) statement in the ext_tables.sql and install the plugin
(This is a valid SQL Statement and works if executed manually, also queries to that statement work if executed manually)
2) install the plugin
3) check if table is created
#
# Table structure for table 'tx_mymodel_domain_model_xyz'
#
CREATE TABLE `tx_invngtr_domain_model_xyz` (
`uid` int(11) NOT NULL AUTO_INCREMENT,
`pid` int(11) NOT NULL DEFAULT '0',
`alter` int(4) unsigned not null,
`tstamp` int(11) unsigned NOT NULL DEFAULT '0',
`crdate` int(11) unsigned NOT NULL DEFAULT '0',
`cruser_id` int(11) unsigned NOT NULL DEFAULT '0',
`deleted` tinyint(4) unsigned NOT NULL DEFAULT '0',
`hidden` tinyint(4) unsigned NOT NULL DEFAULT '0',
`starttime` int(11) unsigned NOT NULL DEFAULT '0',
`endtime` int(11) unsigned NOT NULL DEFAULT '0',
`t3ver_oid` int(11) NOT NULL DEFAULT '0',
`t3ver_id` int(11) NOT NULL DEFAULT '0',
`t3ver_wsid` int(11) NOT NULL DEFAULT '0',
`t3ver_state` tinyint(4) NOT NULL DEFAULT '0',
`t3ver_label` varchar(255) NOT NULL DEFAULT '',
`t3ver_stage` int(11) NOT NULL DEFAULT '0',
`t3ver_count` int(11) NOT NULL DEFAULT '0',
`t3ver_tstamp` int(11) NOT NULL DEFAULT '0',
`t3ver_move_id` int(11) NOT NULL DEFAULT '0',
`sys_language_uid` int(11) NOT NULL DEFAULT '0',
`l10n_parent` int(11) NOT NULL DEFAULT '0',
`l10n_diffsource` mediumblob,
PRIMARY KEY (`uid`),
KEY `parent` (`pid`),
KEY `t3ver_oid` (`t3ver_oid`,`t3ver_wsid`),
KEY `language` (`l10n_parent`,`sys_language_uid`)
);
Expected Result: The Table gets created if i install the plugin
Actual Result: The Table is missing after installing the plugin, no errors displayed anywhere
Typo3 Version: 7.6.17
PHP-Version: 5.6.30
OS: Centos Linux 7
Files
Updated by Fabian Keilholz about 7 years ago
Addition:
The same statement works if i replace "alter" by "age"; The table gets created in this case.
Updated by M S about 7 years ago
Fabian Keilholz wrote:
Addition:
The same statement works if i replace "alter" by "age"; The table gets created in this case.
It would be much better if you don't use keywords and reserved words for fields. How about to use "age" or maybe "das_alter" instead of "alter"?
Have a look at: https://dev.mysql.com/doc/refman/5.5/en/keywords.html
Updated by Mathias Schreiber about 7 years ago
I'd argue that it should not silently fail, but I still want TYPO3 to fail here.
Using reserved words are a problem, and even though MySQL et all give you a way around this using backticks, this will fail on other database systems.
Updated by Fabian Keilholz about 7 years ago
I agree with Mathias Schreiber,
it's not a problem to fail if reserved keywords are used as column name.
(For that matter, theres no error if you have an actual syntax error in the sql, too. Neither visual, nor in the php-error log or the typo log.)
While above case, as well as having syntax errors, is something you should avoid in general, some information while something fails would save lots of time looking for the place where and why it fails.
For me, i simply changed the column name to a non-reserved keyword everywhere and was fine with it; The situation occured because i had a non-typo table and wrapped the typo fields around to use it in an extention.
Updated by Gerrit Code Review about 7 years ago
- Status changed from New to Under Review
Patch set 1 for branch TYPO3_7-6 of project Packages/TYPO3.CMS has been pushed to the review server.
It is available at https://review.typo3.org/54497
Updated by Nicole Cordes about 7 years ago
The error occurs in 7.6 only. With the introduction of doctrine dbal the field names are escaped by default. The patch introduces a new exception type that is caught during upload / installation of an extension. I didn't tested the error for an installation of a TER extension.
Updated by Gerrit Code Review almost 7 years ago
Patch set 2 for branch TYPO3_7-6 of project Packages/TYPO3.CMS has been pushed to the review server.
It is available at https://review.typo3.org/54497
Updated by Gerrit Code Review almost 7 years ago
Patch set 3 for branch TYPO3_7-6 of project Packages/TYPO3.CMS has been pushed to the review server.
It is available at https://review.typo3.org/54497
Updated by Nicole Cordes over 6 years ago
- Status changed from Under Review to Resolved
- % Done changed from 0 to 100
Applied in changeset 7784945a8fe2b81b8aa321d87ae24954c770fc4c.