Bug #82245

Installing a plugin failes to create table if a field is named 'alter'

Added by Fabian Keilholz over 4 years ago. Updated over 3 years ago.

Status:
Closed
Priority:
Should have
Assignee:
-
Category:
Extension Manager
Target version:
-
Start date:
2017-08-30
Due date:
% Done:

100%

Estimated time:
TYPO3 Version:
7
PHP Version:
5.6
Tags:
Complexity:
Is Regression:
Sprint Focus:

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

issue82245_1.0.0_201710292032.zip (3.57 KB) issue82245_1.0.0_201710292032.zip Nicole Cordes, 2017-10-29 20:33
#1

Updated by Fabian Keilholz over 4 years ago

Addition:
The same statement works if i replace "alter" by "age"; The table gets created in this case.

#2

Updated by M S over 4 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

#3

Updated by Mathias Schreiber over 4 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.

#4

Updated by Fabian Keilholz over 4 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.

#5

Updated by Gerrit Code Review about 4 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

#6

Updated by Nicole Cordes about 4 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.

#7

Updated by Gerrit Code Review almost 4 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

#8

Updated by Gerrit Code Review almost 4 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

#9

Updated by Nicole Cordes over 3 years ago

  • Status changed from Under Review to Resolved
  • % Done changed from 0 to 100
#10

Updated by Benni Mack over 3 years ago

  • Status changed from Resolved to Closed

Also available in: Atom PDF