From 79cca074cd7be1cdf52220706445b167c7a247bb Mon Sep 17 00:00:00 2001 From: Alex Pott <alex.a.pott@googlemail.com> Date: Thu, 12 Mar 2020 00:20:09 +0000 Subject: [PATCH] =?UTF-8?q?Issue=20#3119017=20by=20G=C3=A1bor=20Hojtsy,=20?= =?UTF-8?q?effulgentsia,=20catch,=20daffie:=20Tests=20fail=20with=20MariaD?= =?UTF-8?q?B=2010.2.7,=20but=20not=2010.3.22?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- core/lib/Drupal/Core/Database/Install/Tasks.php | 17 ++++++++++++++++- 1 file changed, 16 insertions(+), 1 deletion(-) diff --git a/core/lib/Drupal/Core/Database/Install/Tasks.php b/core/lib/Drupal/Core/Database/Install/Tasks.php index 1cc1d131a50a..5d36603ae880 100644 --- a/core/lib/Drupal/Core/Database/Install/Tasks.php +++ b/core/lib/Drupal/Core/Database/Install/Tasks.php @@ -188,7 +188,22 @@ protected function runTestQuery($query, $pass, $fail, $fatal = FALSE) { */ protected function checkEngineVersion() { // Ensure that the database server has the right version. - if ($this->minimumVersion() && version_compare(Database::getConnection()->version(), $this->minimumVersion(), '<')) { + // We append '-AnyName' to the minimum version for comparison purposes, so + // that engines that append a package name or other build information to + // their version strings still pass. For example, MariaDB might report its + // version as '10.2.7-MariaDB' or '10.2.7+maria' or similar. + // version_compare() treats '-' and '+' as equivalent, and non-numeric + // parts other than conventional stability specifiers (dev, alpha, beta, + // etc.) as equal to each other and less than numeric parts and stability + // specifiers. In other words, 10.2.7-MariaDB, 10.2.7+maria, and + // 10.2.7-AnyName are all equal to each other and less than 10.2.7-alpha. + // This means that by appending '-AnyName' for the comparison check, that + // alpha and other pre-release versions of the minimum will pass this + // check, which isn't ideal; however, people running pre-release versions + // of database servers should know what they're doing, whether Drupal warns + // them or not. + // @see https://www.php.net/manual/en/function.version-compare.php + if ($this->minimumVersion() && version_compare(Database::getConnection()->version(), $this->minimumVersion() . '-AnyName', '<')) { $this->fail(t("The database server version %version is less than the minimum required version %minimum_version.", ['%version' => Database::getConnection()->version(), '%minimum_version' => $this->minimumVersion()])); } } -- GitLab