From d1e9962926108b7e30f386c1ad9353c2f3be9886 Mon Sep 17 00:00:00 2001 From: brandonkelly Date: Sat, 6 Nov 2021 11:28:26 -0700 Subject: [PATCH] Check MariaDB version --- server/requirements/RequirementsChecker.php | 1 + server/requirements/requirements.php | 25 +++++++++++++++------ 2 files changed, 19 insertions(+), 7 deletions(-) diff --git a/server/requirements/RequirementsChecker.php b/server/requirements/RequirementsChecker.php index 7067dcd..d615e25 100644 --- a/server/requirements/RequirementsChecker.php +++ b/server/requirements/RequirementsChecker.php @@ -51,6 +51,7 @@ class RequirementsChecker var $result; var $requiredMySqlVersion = '5.7.8'; + var $requiredMariaDbVersion = '10.2.7'; var $requiredPgSqlVersion = '9.5'; /** diff --git a/server/requirements/requirements.php b/server/requirements/requirements.php index 969f40f..21e8062 100644 --- a/server/requirements/requirements.php +++ b/server/requirements/requirements.php @@ -24,23 +24,34 @@ 'memo' => 'The PDO MySQL extension is required.' ); if ($conn !== false) { + $version = $conn->getAttribute(PDO::ATTR_SERVER_VERSION); + if (strpos($version, 'MariaDB') !== false) { + $name = 'MariaDB'; + $version = preg_replace('/^.*?MariaDB.*?:/', '', $version); + $requiredVersion = $this->requiredMariaDbVersion; + $tzUrl = 'https://mariadb.com/kb/en/time-zones/#mysql-time-zone-tables'; + } else { + $name = 'MySQL'; + $requiredVersion = $this->requiredMySqlVersion; + $tzUrl = 'https://dev.mysql.com/doc/refman/5.7/en/time-zone-support.html'; + } $requirements[] = array( - 'name' => "MySQL {$this->requiredMySqlVersion}+", + 'name' => "{$name} {$requiredVersion}+", 'mandatory' => true, - 'condition' => $this->checkDatabaseServerVersion($conn, $this->requiredMySqlVersion), - 'memo' => "MySQL {$this->requiredMySqlVersion} or higher is required to run Craft CMS.", + 'condition' => version_compare($version, $requiredVersion, '>='), + 'memo' => "{$name} {$this->requiredMySqlVersion} or higher is required to run Craft CMS.", ); $requirements[] = array( - 'name' => 'MySQL InnoDB support', + 'name' => "{$name} InnoDB support", 'mandatory' => true, 'condition' => $this->isInnoDbSupported($conn), - 'memo' => 'Craft CMS requires the MySQL InnoDB storage engine to run.', + 'memo' => "Craft CMS requires the {$name} InnoDB storage engine to run.", ); $requirements[] = array( - 'name' => 'MySQL timezone support', + 'name' => "{$name} timezone support", 'mandatory' => false, 'condition' => $this->validateDatabaseTimezoneSupport($conn), - 'memo' => 'MySQL should be configured with full timezone support.', + 'memo' => "{$name} should be configured with full timezone support.", ); } break;