Bug #85524

Charset for DB Connections in LocalConfiguration.php ignored

Added by David Henninger 11 months ago. Updated 13 days ago.

Status:
Closed
Priority:
Should have
Assignee:
-
Category:
Database API (Doctrine DBAL)
Target version:
-
Start date:
2018-07-09
Due date:
% Done:

100%

TYPO3 Version:
8
PHP Version:
7.0
Tags:
Complexity:
Is Regression:
Sprint Focus:

Description

Currently, the charset value in the DB Connection is being ignored, so Typo3 defaults to utf8, no matter what charset you put in there. Example:

[
    'DB' => [
        'Connections' => [
            'Default' => [
                'charset' => 'utf8mb4',
                'driver' => 'mysqli',
                'host' => '127.0.0.1',
                'port' => 3306,
                'dbname' => 'typo3',
                'user' => 'typo3',
                'password' => 'typo3',
            ],
        ],
    ]
]

Even with MySQL/MariaDB fully configured to use utf8mb4, Typo3 sticks with utf8 and throws the appropriate error:
"It looks like the character set utf8 is not used for this connection even though it is configured as connection charset. This TYPO3 installation is using the $GLOBALS['TYPO3_CONF_VARS']['SYS']['setDBinit'] property with the following value: "". Please make sure that this command does not overwrite the configured charset. Please note that for the TYPO3 database everything other than utf8 is unsupported since version 4.7."

As the error suggests, Typo3 8.7.16 doesn't seem to accept anything beside utf8, so it ignores the option entirely. Directly changing the default to utf8mb4 in sysext/core/Classes/Database/DatabaseConnection.php, but this hack really should not be used.

Unfortunately, without utf8mb4 and just 3-byte utf8, most Emojis are not supported, so switching to utf8mb4 is the only way to get it working. The same issue came up in #71454 already and got "solved": Maybe it has stopped working since then, maybe it never did, either way, currently it's just not working.


Related issues

Related to TYPO3 Core - Bug #87827: Wrong default database charset applied Closed 2019-03-03
Duplicates TYPO3 Core - Feature #80398: Make default charset and collation for new tables configurable Closed 2017-03-22

Associated revisions

Revision 384d38a2 (diff)
Added by Sascha Egerer 3 months ago

[BUGFIX] Initialize database connection with defined character set

The character set must be set based on the configured value
to prevent an exception #1389697515 to be thrown

Related: #71454
Resolves: #85524
Releases: 8.7

Change-Id: I34701429083b4ab7fc568fa1ee94756a49b45da6
Reviewed-on: https://review.typo3.org/c/59323
Tested-by: TYPO3com <>
Tested-by: Susanne Moog <>
Tested-by: Anja Leichsenring <>
Reviewed-by: Oliver Klee <>
Reviewed-by: Susanne Moog <>
Reviewed-by: Anja Leichsenring <>

Revision bd1ea509 (diff)
Added by Nicole Cordes about 2 months ago

[BUGFIX] Ensure correct default database charset

This patch ensures the default charset for the database connection is
set to "utf8".

The charset would normally be set by the SilentConfigurationUpgradeService
but it might be unset when $GLOBALS['TYPO3_CONF_VARS']['DB'] is
overwritten in AdditionalConfiguration.php.

Releases: 8.7
Resolves: #87827
Related: #85524
Change-Id: Ifc630d479866889959fe69ceb213439b8ce734f7
Reviewed-on: https://review.typo3.org/c/Packages/TYPO3.CMS/+/59835
Tested-by: Benjamin Franzke <>
Tested-by: TYPO3com <>
Tested-by: Nicole Cordes <>
Tested-by: Benni Mack <>
Reviewed-by: Benjamin Franzke <>
Reviewed-by: Oliver Klee <>
Reviewed-by: Sascha Egerer <>
Reviewed-by: Nicole Cordes <>
Reviewed-by: Benni Mack <>

History

#1 Updated by David Henninger 10 months ago

  • Duplicates Feature #80398: Make default charset and collation for new tables configurable added

#2 Updated by Riccardo De Contardi 10 months ago

  • Status changed from New to Closed

Closed as a duplicate of #80398 please continue the discussion there - there is already a patch attached. Thank you.

If you think that this is the wrong decision, please reopen it or ping me.

#3 Updated by Sascha Egerer 5 months ago

  • Status changed from Closed to Accepted

#80398 is only related to TYPO3 master. But the problem does still exist in TYPO3 8

#4 Updated by Gerrit Code Review 5 months ago

  • Status changed from Accepted to Under Review

Patch set 1 for branch TYPO3_8-7 of project Packages/TYPO3.CMS has been pushed to the review server.
It is available at https://review.typo3.org/59323

#5 Updated by Gerrit Code Review 5 months ago

Patch set 2 for branch TYPO3_8-7 of project Packages/TYPO3.CMS has been pushed to the review server.
It is available at https://review.typo3.org/59323

#6 Updated by Gerrit Code Review 3 months ago

Patch set 3 for branch TYPO3_8-7 of project Packages/TYPO3.CMS has been pushed to the review server.
It is available at https://review.typo3.org/c/Packages/TYPO3.CMS/+/59323

#7 Updated by Gerrit Code Review 3 months ago

Patch set 4 for branch TYPO3_8-7 of project Packages/TYPO3.CMS has been pushed to the review server.
It is available at https://review.typo3.org/c/Packages/TYPO3.CMS/+/59323

#8 Updated by Sascha Egerer 3 months ago

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

#9 Updated by Nicole Cordes 3 months ago

  • Related to Bug #87827: Wrong default database charset applied added

#10 Updated by Benni Mack 13 days ago

  • Status changed from Resolved to Closed

Also available in: Atom PDF