Improve database collation detection #22594
Merged
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Description:
The collation detection introduced in #22564 can create problems in some environments, most likely for MariaDB 11.4+.
In MariaDB 11.4+ the query
SHOW COLLATION WHERE `Default` = "Yes" AND `Charset` = 'utf8mb4'
does not return any result, and throwing an exception means a new installation is not possible. Showing the diagnostics page also crashes if no collation is configured.When updating an existing Matomo installation, the update migration should detect a collation to prevent this problem. However, if there are already mixed tables (e.g. users table with
general_ci
and archive table withuca1400_ai_ci
) this is not something we can be really sure of.The check is changed to use
SHOW CHARACTER SET
instead. This should, at least forutf8mb4
character sets, always return a default we can use for installation/diagnostics. Forutf8
, or if there is no value found, it will now return an empty string. With the updatedCREATE DATABASE
statement, this should now allow installation for MariaDB 11.4+ again, and also for database setups that are not configured to handleutf8mb4
.Forcing
utf8
charset detection during installutf8mb3
innodb_file_per_table
for the server:The configuration should be created as
[database] charset = utf8
(missing fromconfig.ini.php
because this is the default fromglobal.ini.php
), and no collation.Review