From 71611510a0d676742b8e69119f1149eaaa633ce7 Mon Sep 17 00:00:00 2001 From: Mark Nelson Date: Thu, 26 Feb 2015 19:01:37 -0800 Subject: [PATCH] MDL-46064 install: prevent install/upgrade with MyISAM --- admin/environment.xml | 128 +++++++++++++++++++++ lang/en/admin.php | 1 + lib/dml/mariadb_native_moodle_database.php | 20 ---- lib/upgradelib.php | 24 ++++ 4 files changed, 153 insertions(+), 20 deletions(-) diff --git a/admin/environment.xml b/admin/environment.xml index 38ec017a39b..27a0b5a3e2f 100644 --- a/admin/environment.xml +++ b/admin/environment.xml @@ -1259,4 +1259,132 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/lang/en/admin.php b/lang/en/admin.php index 69dbb497bc9..35c0ef18eae 100644 --- a/lang/en/admin.php +++ b/lang/en/admin.php @@ -1067,6 +1067,7 @@ $string['uninstallplugin'] = 'Uninstall'; $string['unlockaccount'] = 'Unlock account'; $string['unsettheme'] = 'Unset theme'; $string['unsupported'] = 'Unsupported'; +$string['unsupporteddbstorageengine'] = 'The database storage engine being used is no longer supported.'; $string['unsuspenduser'] = 'Activate user account'; $string['updateaccounts'] = 'Update existing accounts'; $string['updatecomponent'] = 'Update component'; diff --git a/lib/dml/mariadb_native_moodle_database.php b/lib/dml/mariadb_native_moodle_database.php index 12dc9ebefff..ffc77965932 100644 --- a/lib/dml/mariadb_native_moodle_database.php +++ b/lib/dml/mariadb_native_moodle_database.php @@ -101,24 +101,4 @@ class mariadb_native_moodle_database extends mysqli_native_moodle_database { } return true; } - - /** - * Returns the current db engine. - * - * MyISAM is NOT supported! - * - * @return string or null MySQL engine name - */ - public function get_dbengine() { - if ($this->external) { - return null; - } - - $engine = parent::get_dbengine(); - if ($engine === 'MyISAM') { - debugging('MyISAM tables are not supported in MariaDB driver!'); - $engine = 'XtraDB'; - } - return $engine; - } } diff --git a/lib/upgradelib.php b/lib/upgradelib.php index 492a62865fd..237b0633f12 100644 --- a/lib/upgradelib.php +++ b/lib/upgradelib.php @@ -2203,3 +2203,27 @@ function upgrade_fix_missing_root_folders_draft() { $rs->close(); $transaction->allow_commit(); } + +/** + * This function verifies that the database is not using an unsupported storage engine. + * + * @param environment_results $result object to update, if relevant + * @return environment_results|null updated results object, or null if the storage engine is supported + */ +function check_database_storage_engine(environment_results $result) { + global $DB; + + // Check if MySQL is the DB family (this will also be the same for MariaDB). + if ($DB->get_dbfamily() == 'mysql') { + // Get the database engine we will either be using to install the tables, or what we are currently using. + $engine = $DB->get_dbengine(); + // Check if MyISAM is the storage engine that will be used, if so, do not proceed and display an error. + if ($engine == 'MyISAM') { + $result->setInfo('unsupported_db_storage_engine'); + $result->setStatus(false); + return $result; + } + } + + return null; +}