### Eclipse Workspace Patch 1.0 #P moodle20r Index: lib/dml/moodle_database.php =================================================================== RCS file: /cvsroot/moodle/moodle/lib/dml/moodle_database.php,v retrieving revision 1.114 diff -u -r1.114 moodle_database.php --- lib/dml/moodle_database.php 25 Jul 2010 20:18:39 -0000 1.114 +++ lib/dml/moodle_database.php 5 Aug 2010 20:27:49 -0000 @@ -237,6 +237,16 @@ } /** + * Diagnose database and tables, this function is used + * to verify database and driver settings, db engine types, etc. + * + * @return string null means everything ok, string means problem found. + */ + public function diagnose() { + return null; + } + + /** * Connect to db * Must be called before other methods. * @param string $dbhost Index: lib/dml/mysqli_native_moodle_database.php =================================================================== RCS file: /cvsroot/moodle/moodle/lib/dml/mysqli_native_moodle_database.php,v retrieving revision 1.52 diff -u -r1.52 mysqli_native_moodle_database.php --- lib/dml/mysqli_native_moodle_database.php 31 Jul 2010 20:51:23 -0000 1.52 +++ lib/dml/mysqli_native_moodle_database.php 5 Aug 2010 20:27:49 -0000 @@ -144,6 +144,36 @@ } /** + * Diagnose database and tables, this function is used + * to verify database and driver settings, db engine types, etc. + * + * @return string null means everything ok, string means problem found. + */ + public function diagnose() { + $sloppymyisamfound = false; + $prefix = str_replace('_', '\\_', $this->prefix); + $sql = "SHOW TABLE STATUS WHERE Name LIKE BINARY '$prefix%'"; + $this->query_start($sql, null, SQL_QUERY_AUX); + $result = $this->mysqli->query($sql); + $this->query_end($result); + if ($result) { + while ($arr = $result->fetch_assoc()) { + if ($arr['Engine'] === 'MyISAM') { + $sloppymyisamfound = true; + break; + } + } + $result->close(); + } + + if ($sloppymyisamfound) { + return 'Some database tables are using unreliable MyISAM database engine, it is strongly recommended to migrate them to InnoDB or other reliable MySQL storage engine.'; //TODO: localize + } else { + return null; + } + } + + /** * Connect to db * Must be called before other methods. * @param string $dbhost Index: admin/index.php =================================================================== RCS file: /cvsroot/moodle/moodle/admin/index.php,v retrieving revision 1.423 diff -u -r1.423 index.php --- admin/index.php 18 Jul 2010 07:17:01 -0000 1.423 +++ admin/index.php 5 Aug 2010 20:27:47 -0000 @@ -373,6 +373,12 @@ echo $OUTPUT->box(get_string('bloglevelupgradenotice', 'admin'), 'generalbox adminwarning'); } +// diagnose DB, especially the sloppy MyISAM tables! +$diagnose = $DB->diagnose(); +if ($diagnose !== NULL) { + echo $OUTPUT->box($diagnose, 'generalbox adminwarning'); +} + // Alert if we are currently in maintenance mode if (!empty($CFG->maintenance_enabled)) { echo $OUTPUT->box(get_string('sitemaintenancewarning2', 'admin', "$CFG->wwwroot/$CFG->admin/settings.php?section=maintenancemode"), 'generalbox adminwarning');