Skip to content

Commit

Permalink
MDL-51080 env: warn when running MariaDB w/ wrong dbtype
Browse files Browse the repository at this point in the history
  • Loading branch information
scara authored and stronk7 committed Jun 27, 2018
1 parent b088c6d commit 5040258
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 0 deletions.
1 change: 1 addition & 0 deletions lang/en/admin.php
Expand Up @@ -526,6 +526,7 @@
$string['environmentsettingok'] = 'recommended setting detected';
$string['environmentshouldfixsetting'] = 'PHP setting should be changed.';
$string['environmentxmlerror'] = 'Error reading environment data ({$a->error_code})';
$string['environmentmariadbwrongdbtype'] = 'Wrong <code>$CFG->dbtype</code>: you need to change it in your <code>config.php</code> file, from \'<code>mysql</code>\' to \'<code>mariadb</code>\'.';
$string['errordeletingconfig'] = 'An error occurred while deleting the configuration records for plugin \'{$a}\'.';
$string['errorsetting'] = 'Could not save setting:';
$string['errorwithsettings'] = 'Some settings were not changed due to an error.';
Expand Down
13 changes: 13 additions & 0 deletions lib/environmentlib.php
Expand Up @@ -1048,6 +1048,19 @@ function environment_check_database($version, $env_select) {
return $result;
}

// Check if the DB Vendor has been properly configured.
// Hack: this is required when playing with MySQL and MariaDB since they share the same PHP module and base DB classes,
// whilst they are slowly evolving using separate directions though MariaDB is still an "almost" drop-in replacement.
$dbvendorismysql = ($current_vendor === 'mysql');
$dbtypeismariadb = (stripos($dbinfo['description'], 'mariadb') !== false);
if ($dbvendorismysql && $dbtypeismariadb) {
$result->setStatus(false);
$result->setLevel($level);
$result->setInfo($current_vendor . ' (' . $dbinfo['description'] . ')');
$result->setFeedbackStr('environmentmariadbwrongdbtype');
return $result;
}

/// And finally compare them, saving results
if (version_compare($current_version, $needed_version, '>=')) {
$result->setStatus(true);
Expand Down

0 comments on commit 5040258

Please sign in to comment.