Project

General

Profile

Actions

Bug #41596

closed

Content of $TYPO3_CONF_VARS['SYS']['setDBinit'] is completely overruled / ignored

Added by Jörg Wagner over 11 years ago. Updated over 5 years ago.

Status:
Closed
Priority:
Must have
Assignee:
-
Category:
-
Target version:
-
Start date:
2012-10-04
Due date:
% Done:

100%

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

Description

The Install tool of 4.7 still offers an option to enter a value for ['SYS']['setDBinit'] and the value entered here is written into localconf.php without any restriction or modification.

But that value is then completely ignored by the core and always internally overwritten with 'SET NAMES utf8;'.
While the intention behind this is clear (TYPO3 forces UTF-8 since 4.7) there is a severe flaw in this logic:

setDBinit is by far not only needed to set the character set of the DB communication.
setDBinit is used for ANY initial configuration of the MySQL DB and is very much needed beyond any "SET NAMES" clauses!

Example

One of the most important examples of usages of setDBinit would be to switch MySQL 5.1 from strict mode to compatibility mode using this setting:

$TYPO3_CONF_VARS['SYS']['setDBinit'] = "SET SESSION sql_mode='MYSQL40';";

Strict mode is recommended by MySQL 5.1 documentation so this should be the standard for any current MySQL installation. TYPO3 should not expect the whole webserver to be configured in a deprecated MySQL 4.0 compatibility mode. Using setDBinit is the ONLY way to configure MySQL in compatibility mode for TYPO3 while keeping strict mode as the standard for all other installations on the same server.
Without this possibility there is no way to get TYPO3 to run on a modern MySQL setup as the backend login will always fail in strict mode.

Background

In /t3lib/config_default.php the following block checks the ['SYS']['setDBinit'] config var:

if (isset($TYPO3_CONF_VARS['SYS']['setDBinit']) &&
    $TYPO3_CONF_VARS['SYS']['setDBinit'] !== '-1' &&
    preg_match('/SET NAMES utf8/', $TYPO3_CONF_VARS['SYS']['setDBinit']) === FALSE &&
    TYPO3_enterInstallScript !== '1'
) {
        // Only accept "SET NAMES utf8" for this setting, otherwise die with a nice error
    die('This TYPO3 installation is using the $TYPO3_CONF_VARS[\'SYS\'][\'setDBinit\'] property with the following value:' . chr(10) .
        $TYPO3_CONF_VARS['SYS']['setDBinit'] . chr(10) . chr(10) .
        'It looks like UTF-8 is not used for this connection.' . chr(10) . chr(10) .
        'Everything other than UTF-8 is unsupported since TYPO3 4.7.' . chr(10) .
        'The DB, its connection and TYPO3 should be migrated to UTF-8 therefore. Please check your setup.');
} else {
    $TYPO3_CONF_VARS['SYS']['setDBinit'] = 'SET NAMES utf8;';
}

As you can see, there are only two possible outcomes:
1. An error is thrown
2. The value of ['SYS']['setDBinit'] is overwritten with 'SET NAMES utf8;'

Solution

The code block above must be modified to check for "SET NAMES" clauses. Any such clauses can be rejected altogether (read: throw an error) as 'SET NAMES utf8;' is set by default and is the only option allowed.
After this test has passed successfully, the standard 'SET NAMES utf8;' clause must be added (NOT replace!!!) to any existing setDBinit content. This will allow to use commands like the above "SET SESSION sql_mode" while still forcing the UTF-8 setting of modern TYPO3 versions.

I will post a corresponding patch asap.


Files

20121004_Patch_41596_4.7.4.diff (1.55 KB) 20121004_Patch_41596_4.7.4.diff Jörg Wagner, 2012-10-04 18:21

Related issues 3 (0 open3 closed)

Related to TYPO3 Core - Bug #24582: Accept alternative notations for setDBinitClosed2011-01-15

Actions
Related to TYPO3 Core - Bug #36754: SQL warning about collation in the install tool, Upgrade wizardClosed2012-05-01

Actions
Has duplicate TYPO3 Core - Bug #55016: Install tool fails to change 'setDBinit'Closed2014-01-15

Actions
Actions

Also available in: Atom PDF