From: stronk7 Date: Sat, 30 Sep 2006 10:54:37 +0000 (+0000) Subject: Execute the index_get_name() silently to avoid a lot of X-Git-Url: http://git.mjollnir.org/gw?a=commitdiff_plain;h=ef18962b0044cbf345b467bebe31ac37bf64dfc0;p=moodle.git Execute the index_get_name() silently to avoid a lot of output in the install/upgrade process. Original db->debug is re-set to their original status once executed. --- diff --git a/lib/ddllib.php b/lib/ddllib.php index 844c8ad9d8..bf956e56df 100644 --- a/lib/ddllib.php +++ b/lib/ddllib.php @@ -308,9 +308,24 @@ function find_index_name($xmldb_table, $xmldb_index) { global $CFG, $db; +/// Do this function silenty (to avoid output in install/upgrade process) + $olddbdebug = $db->debug; + $db->debug = false; + /// Extract index columns $indcolumns = $xmldb_index->getFields(); +/// Calculate table name + $tablename = $CFG->prefix . $xmldb_table->getName(); + +/// Check the table exists + $metatables = $db->MetaTables(); + $metatables = array_change_key_case($metatables, CASE_LOWER); + if (!array_key_exists($tablename, $metatables)) { + $db->debug = $olddbdebug; //Re-set original $db->debug + return false; + } + /// Get list of indexes in table $indexes = null; if ($indexes = $db->MetaIndexes($CFG->prefix . $xmldb_table->getName())) { @@ -329,11 +344,13 @@ function find_index_name($xmldb_table, $xmldb_index) { $diferences = array_merge(array_diff($columns, $indcolumns), array_diff($indcolumns, $columns)); /// If no diferences, we have find the index if (empty($diferences)) { + $db->debug = $olddbdebug; //Re-set original $db->debug return $indexname; } } } /// Arriving here, index not found + $db->debug = $olddbdebug; //Re-set original $db->debug return false; }