diff --git a/core/lib/Drupal/Core/Database/Driver/mysql/Install/Tasks.php b/core/lib/Drupal/Core/Database/Driver/mysql/Install/Tasks.php index 271cdafe57..7f3d2ef841 100644 --- a/core/lib/Drupal/Core/Database/Driver/mysql/Install/Tasks.php +++ b/core/lib/Drupal/Core/Database/Driver/mysql/Install/Tasks.php @@ -61,20 +61,37 @@ public function name() { */ public function minimumVersion() { $version = Database::getConnection()->version(); + $distro = $this->getDistributionFromVersion($version); + if ($distro === 'mariadb') { + return self::MARIADB_MINIMUM_VERSION; + } + + return self::MYSQL_MINIMUM_VERSION; + } + + /** + * Determines which MySQL-equivalent distribution a given version signifies. + * + * @param string $version + * The version string. + * + * @return string + * The distribution name. + */ + protected function getDistributionFromVersion(string $version): string { // MariaDB's version numbers diverged from MySQL's after 5.5. // @see https://downloads.mariadb.org/mariadb/+releases/ - // Since then they take the form "x.y.z-MariaDB" and have a different - // minimum requirement. Earlier versions can fall back to MySQL's minimum. + // Since then they take the form "x.y.z-MariaDB". Earlier versions can be + // safely treated as MySQL. if (stripos($version, 'mariadb')) { - return self::MARIADB_MINIMUM_VERSION; + return 'mariadb'; } - // MySQL and Percona Server version numbers stay in sync and have the same - // minimum requirement. + // MySQL and Percona Server version numbers stay in sync. // @see https://downloads.mysql.com/archives/community/ // @see https://www.percona.com/doc/percona-server/LATEST/release-notes/release-notes_index.html - return self::MYSQL_MINIMUM_VERSION; + return 'mysql'; } /** diff --git a/core/tests/Drupal/Tests/Core/Database/Driver/mysql/MysqlTasksTest.php b/core/tests/Drupal/Tests/Core/Database/Driver/mysql/MysqlTasksTest.php new file mode 100644 index 0000000000..e41b5d6093 --- /dev/null +++ b/core/tests/Drupal/Tests/Core/Database/Driver/mysql/MysqlTasksTest.php @@ -0,0 +1,38 @@ +getDistributionFromVersion($version); + + $this->assertEquals($expected, $actual); + } + + public function providerGetDistributionFromVersion(): array { + return [ + 'MariaDB' => ['10.2.0-MariaDB', 'mariadb'], + 'MySQL' => ['5.7.28', 'mysql'], + 'Percona Server' => ['5.7.28-31', 'mysql'], + 'Default' => ['Literally anything else', 'mysql'], + ]; + } + +}