Empowering People Ethically with the leading open source alternative to Google Analytics that gives you full control over your data. Matomo lets you easily collect data from websites & apps and visualise this data and extract insights. Privacy is built-in. Liberating Web Analytics. Star us on Github? +1. And we love Pull Requests!
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 with uca1400_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 for utf8mb4 character sets, always return a default we can use for installation/diagnostics. For utf8, or if there is no value found, it will now return an empty string. With the updated CREATE DATABASE statement, this should now allow installation for MariaDB 11.4+ again, and also for database setups that are not configured to handle utf8mb4.
Forcing utf8 charset detection during install
Start a database server, for example MySQL 8.0
Create a database with utf8mb3
CREATE DATABASE matomo CHARSET utf8mb3;
Deactivate innodb_file_per_table for the server:
SET GLOBAL innodb_file_per_table = OFF;
Proceed to install Matomo
The configuration should be created as [database] charset = utf8 (missing from config.ini.php because this is the default from global.ini.php), and no collation.
[ ] Potential edge cases thought about (behavior of the code with strange input, with strange internal state or possible interactions with other Matomo subsystems)
[ ] Usability review done (is anything maybe unclear or think about anything that would cause people to reach out to support)
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