Skip to content

Commit

Permalink
Check MariaDB version
Browse files Browse the repository at this point in the history
  • Loading branch information
brandonkelly committed Nov 6, 2021
1 parent 2ba43a8 commit d1e9962
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 7 deletions.
1 change: 1 addition & 0 deletions server/requirements/RequirementsChecker.php
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,7 @@ class RequirementsChecker
var $result;

var $requiredMySqlVersion = '5.7.8';
var $requiredMariaDbVersion = '10.2.7';
var $requiredPgSqlVersion = '9.5';

/**
Expand Down
25 changes: 18 additions & 7 deletions server/requirements/requirements.php
Original file line number Diff line number Diff line change
Expand Up @@ -24,23 +24,34 @@
'memo' => 'The <a rel="noopener" target="_blank" href="https://php.net/manual/en/ref.pdo-mysql.php">PDO MySQL</a> 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 <a rel="noopener" target="_blank" href="https://dev.mysql.com/doc/refman/5.7/en/time-zone-support.html">full timezone support</a>.',
'memo' => "{$name} should be configured with <a rel='noopener' target='_blank' href='{$tzUrl}'>full timezone support</a>.",
);
}
break;
Expand Down

0 comments on commit d1e9962

Please sign in to comment.