Merge branch 'm36_MDL-51080_MAriaDB_Wrong_DB_Type' of https://github.com/scara/moodle

This commit is contained in:
Eloy Lafuente (stronk7) 2018-06-27 23:25:03 +02:00
commit 9d05da3f6d
2 changed files with 14 additions and 0 deletions

View File

@ -529,6 +529,7 @@ $string['environmentrequireversion'] = 'version {$a->needed} is required and you
$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.';

View File

@ -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);