Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .ddev/config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ additional_hostnames: []
additional_fqdns: []
database:
type: mysql
version: "5.7"
version: "8.0"
hooks:
pre-start:
- exec-host: bash .ddev/scripts/configure-platform.sh
Expand Down
8 changes: 6 additions & 2 deletions .github/workflows/matomo-tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -64,11 +64,11 @@ jobs:
- php: '8.1'
adapter: 'PDO_MYSQL'
mysql-engine: 'Mysql'
mysql-version: '5.7'
mysql-version: '8.0'
- php: '8.2'
adapter: 'PDO_MYSQL'
mysql-engine: 'Mariadb'
mysql-version: '11.4'
mysql-version: '10.6'
- php: '8.5'
adapter: 'MYSQLI'
mysql-engine: 'Mysql'
Expand Down Expand Up @@ -400,6 +400,8 @@ jobs:
ui-test-options: '--plugin=${{ matrix.plugin }}'
test-type: 'UI'
php-version: '8.1'
mysql-engine: 'Mysql'
mysql-version: '8.0'
node-version: '16'
redis-service: true
artifacts-pass: ${{ secrets.ARTIFACTS_PASS }}
Expand Down Expand Up @@ -435,6 +437,8 @@ jobs:
--test-group=${{ strategy.job-index }}
test-type: 'UI'
php-version: '8.1'
mysql-engine: 'Mysql'
mysql-version: '8.0'
node-version: '16'
redis-service: true
artifacts-pass: ${{ secrets.ARTIFACTS_PASS }}
Expand Down
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ Matomo is released under the GPL v3 (or later) license, see [LICENSE](LICENSE).
## Requirements

* PHP 8.1.0 or greater
* MySQL version 5.5 or greater, or MariaDB
* MySQL version 8.0 or greater, or MariaDB version 10.6 or greater
* PHP extension pdo and pdo_mysql, or the MySQLi extension
* Matomo is OS / server independent

Expand Down
15 changes: 0 additions & 15 deletions config/environment/ui-test-tidb.php

This file was deleted.

6 changes: 3 additions & 3 deletions config/global.ini.php
Original file line number Diff line number Diff line change
Expand Up @@ -248,7 +248,7 @@

; whether to enable segment archiving cache
; Note: if you use any plugins, this need to be compliant with Matomo and
; * depending on the segment you create you may need a newer MySQL version (eg 5.7 or newer)
; * depending on the segment you create you may need a newer MySQL version (eg 8.0 or newer)
; * use a reader database for archiving in case you have configured a database reader
enable_segments_cache = 1

Expand Down Expand Up @@ -410,7 +410,7 @@
archiving_custom_ranges[] =

; If configured, archiving queries will be aborted after the configured amount of seconds. Set it to -1 if the query time
; should not be limited. Note: This feature requires a recent MySQL version (5.7 or newer) and the PDO\MYSQL extension
; should not be limited. Note: This feature requires a recent database version and the PDO\MYSQL extension
; must be used. Some MySQL forks like MariaDB might not support this feature which uses the MAX_EXECUTION_TIME hint.
; This feature will not work with the MYSQLI extension.
archiving_query_max_execution_time = 7200
Expand Down Expand Up @@ -683,7 +683,7 @@

; If configured, will abort a MySQL query after the configured amount of seconds and show an error in the UI to for
; example lower the date range or tweak the segment (if one is applied). Set it to -1 if the query time should not be
; limited. Note: This feature requires a recent MySQL version (5.7 or newer) and the PDO\MYSQL extension must be used.
; limited. Note: This feature requires a recent database version and the PDO\MYSQL extension must be used.
; Some MySQL forks like MariaDB might not support this feature which uses the MAX_EXECUTION_TIME hint. This feature will
; not work with the MYSQLI extension.
live_query_max_execution_time = -1
Expand Down
5 changes: 0 additions & 5 deletions core/Config/DatabaseConfig.php
Original file line number Diff line number Diff line change
Expand Up @@ -15,9 +15,4 @@ public static function getSectionName(): string
{
return 'database';
}

public static function isTiDb(): bool
{
return self::getConfigValue('schema') === 'Tidb';
}
}
15 changes: 9 additions & 6 deletions core/Db/Adapter/Mysqli.php
Original file line number Diff line number Diff line change
Expand Up @@ -90,22 +90,25 @@ protected function _connect() // phpcs:ignore PSR2.Methods.MethodDeclaration.Und
}

/**
* Check MySQL version
* Checks the database server version against the required minimum for the
* detected server type (MySQL or MariaDB).
*
* @throws Exception
*/
public function checkServerVersion()
{
$requiredVersion = Schema::getInstance()->getMinimumSupportedVersion();
$serverVersion = $this->getServerVersion();
$serverVersion = (string) $this->getServerVersion();
$requiredVersion = Schema::getMinimumSupportedVersionForServer($serverVersion);
$comparableVersion = Schema::getComparableVersion($serverVersion);
$databaseType = Schema::getServerTypeFromVersion($serverVersion);

if (version_compare($serverVersion, $requiredVersion) === -1) {
throw new Exception(Piwik::translate('General_ExceptionDatabaseVersion', array('MySQL', $serverVersion, $requiredVersion)));
if (version_compare($comparableVersion, $requiredVersion) === -1) {
throw new Exception(Piwik::translate('General_ExceptionDatabaseVersion', array($databaseType, $comparableVersion, $requiredVersion)));
}
}

/**
* Returns the MySQL server version
* Returns the raw database server version
*
* @return null|string
*/
Expand Down
15 changes: 9 additions & 6 deletions core/Db/Adapter/Pdo/Mysql.php
Original file line number Diff line number Diff line change
Expand Up @@ -131,22 +131,25 @@ public static function getDefaultPort()
}

/**
* Check MySQL version
* Checks the database server version against the required minimum for the
* detected server type (MySQL or MariaDB).
*
* @throws Exception
*/
public function checkServerVersion()
{
$requiredVersion = Schema::getInstance()->getMinimumSupportedVersion();
$serverVersion = $this->getServerVersion();
$serverVersion = (string) $this->getServerVersion();
$requiredVersion = Schema::getMinimumSupportedVersionForServer($serverVersion);
$comparableVersion = Schema::getComparableVersion($serverVersion);
$databaseType = Schema::getServerTypeFromVersion($serverVersion);

if (version_compare($serverVersion, $requiredVersion) === -1) {
throw new Exception(Piwik::translate('General_ExceptionDatabaseVersion', array('MySQL', $serverVersion, $requiredVersion)));
if (version_compare($comparableVersion, $requiredVersion) === -1) {
throw new Exception(Piwik::translate('General_ExceptionDatabaseVersion', array($databaseType, $comparableVersion, $requiredVersion)));
}
}

/**
* Returns the MySQL server version
* Returns the raw database server version
*
* @return null|string
*/
Expand Down
6 changes: 0 additions & 6 deletions core/Db/BatchInsert.php
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,6 @@
use Exception;
use Piwik\Common;
use Piwik\Config;
use Piwik\Config\DatabaseConfig;
use Piwik\Container\StaticContainer;
use Piwik\Db;
use Piwik\ExceptionHandler;
Expand Down Expand Up @@ -99,11 +98,6 @@ public static function tableInsertBatch($tableName, $fields, $values, $throwExce
}
$filePath = $path . $tableName . '-' . $instanceId . Common::generateUniqId() . '.csv';

// always use utf8 for TiDb, as TiDb has problems with latin1
if (DatabaseConfig::isTiDb()) {
$charset = 'utf8';
}

try {
$fileSpec = array(
'delim' => "\t",
Expand Down
55 changes: 55 additions & 0 deletions core/Db/Schema.php
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,61 @@ public static function getDefaultPortForSchema(string $schemaName): int
return $schemaClass->getDefaultPort();
}

/**
* Extracts a comparable semantic version (e.g. "10.6.19") from a raw database
* server version string.
*
* MariaDB reports its version with a leading "5.5.5-" compatibility prefix for
* old MySQL clients (e.g. "5.5.5-10.6.19-MariaDB"); that prefix is stripped so
* the actual server version is returned.
*/
public static function getComparableVersion(string $databaseVersion): string
{
if (
stripos($databaseVersion, 'mariadb') !== false
&& preg_match('/5\.5\.5-(\d+(?:\.\d+){0,2})-MariaDB/i', $databaseVersion, $matches)
) {
return $matches[1];
}

if (preg_match('/\d+(?:\.\d+){0,2}/', $databaseVersion, $matches)) {
return $matches[0];
}

return $databaseVersion;
}

/**
* Detects the database server type ("MySQL" or "MariaDB") from a raw server
* version string, matching the values returned by getDatabaseType().
*/
public static function getServerTypeFromVersion(string $serverVersion): string
{
if (stripos($serverVersion, 'mariadb') !== false) {
return 'MariaDB';
}

return 'MySQL';
}

/**
* Returns the minimum supported server version to compare the given raw server
* version string against.
*
* The minimum is derived from the actual server type reported in the version
* string rather than from the configured schema, so a server is always held to
* the requirement matching what it really is: a MariaDB server is never checked
* against the MySQL minimum and vice versa, regardless of the schema configured
* in config.ini.php (running MariaDB with the MySQL schema is a supported setup).
*/
public static function getMinimumSupportedVersionForServer(string $serverVersion): string
{
$schemaClassName = self::getSchemaClassName(self::getServerTypeFromVersion($serverVersion));
/** @var SchemaInterface $schemaClass */
$schemaClass = new $schemaClassName();
return $schemaClass->getMinimumSupportedVersion();
}

/**
* Load schema
*/
Expand Down
2 changes: 1 addition & 1 deletion core/Db/Schema/Mariadb.php
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
*/
class Mariadb extends Mysql
{
protected $minimumSupportedVersion = '5.5';
protected $minimumSupportedVersion = '10.6';

public function getDatabaseType(): string
{
Expand Down
2 changes: 1 addition & 1 deletion core/Db/Schema/Mysql.php
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ class Mysql implements SchemaInterface
public const OPTION_NAME_MATOMO_INSTALL_VERSION = 'install_version';
public const MAX_TABLE_NAME_LENGTH = 64;
private $tablesInstalled = null;
protected $minimumSupportedVersion = '5.5';
protected $minimumSupportedVersion = '8.0';

public function getDatabaseType(): string
{
Expand Down
100 changes: 0 additions & 100 deletions core/Db/Schema/Tidb.php

This file was deleted.

13 changes: 1 addition & 12 deletions core/Plugin/ControllerAdmin.php
Original file line number Diff line number Diff line change
Expand Up @@ -323,18 +323,7 @@ private static function getEffectiveDatabaseType(string $databaseType, string $d

private static function getComparableDatabaseVersion(string $databaseVersion): string
{
if (
stripos($databaseVersion, 'mariadb') !== false
&& preg_match('/5\.5\.5-(\d+(?:\.\d+){0,2})-MariaDB/i', $databaseVersion, $matches)
) {
return $matches[1];
}

if (preg_match('/\d+(?:\.\d+){0,2}/', $databaseVersion, $matches)) {
return $matches[0];
}

return $databaseVersion;
return Schema::getComparableVersion($databaseVersion);
}

private static function notifyWhenDatabaseVersionIsNotCompatibleWithNextMajorPiwik(): void
Expand Down
Loading
Loading