]> git.mjollnir.org Git - moodle.git/commitdiff
Execute the index_get_name() silently to avoid a lot of
authorstronk7 <stronk7>
Sat, 30 Sep 2006 10:54:37 +0000 (10:54 +0000)
committerstronk7 <stronk7>
Sat, 30 Sep 2006 10:54:37 +0000 (10:54 +0000)
output in the install/upgrade process. Original db->debug
is re-set to their original status once executed.

lib/ddllib.php

index 844c8ad9d86d3926e375425248e115b6c720d6d3..bf956e56df7ccdff29a016973404c3ef8707bda3 100644 (file)
@@ -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;
 }