]> git.mjollnir.org Git - moodle.git/commitdiff
Don't asume that table and column exist in the migration process.
authorstronk7 <stronk7>
Sat, 2 Sep 2006 23:38:16 +0000 (23:38 +0000)
committerstronk7 <stronk7>
Sat, 2 Sep 2006 23:38:16 +0000 (23:38 +0000)
Just to avoid some warnings.

admin/utfdbmigrate.php

index 420f75eb35ef4627c4933b4da3d1cde7eec5f05a..fdacd778b1704ea4d86b4a894114bd606cf3954b 100755 (executable)
@@ -473,18 +473,20 @@ function db_migrate2utf8(){   //Eloy: Perhaps some type of limit parameter here
                                Note that this code will leave remaining NOT NULL fiels
                                unmodified at all, folowing the old approach 
                             */
-                               $cols = $db->MetaColumns($prefix.$dbtablename);
-                               $cols = array_change_key_case($cols, CASE_LOWER); ///lowercase col names
-                               $notnull = 'NOT NULL';  ///Old default
-                               $col = $cols[strtolower($fieldname)];
-                           /// If the column was null before UTF-8 migration, save it
-                               if (!$col->not_null) {
-                                   $notnull = 'NULL';
-                               /// And, if the column had an empty string as default, make it NULL now
-                                   if ($default == "''") {
-                                       $default = 'NULL';
-                                   }
-                               }
+                            if($cols = $db->MetaColumns($prefix.$dbtablename)) {
+                                $cols = array_change_key_case($cols, CASE_LOWER); ///lowercase col names
+                                $notnull = 'NOT NULL';  ///Old default
+                                if ($col = $cols[strtolower($fieldname)]) {
+                                /// If the column was null before UTF-8 migration, save it
+                                    if (!$col->not_null) {
+                                        $notnull = 'NULL';
+                                    /// And, if the column had an empty string as default, make it NULL now
+                                        if ($default == "''") {
+                                            $default = 'NULL';
+                                        }
+                                    }
+                                }
+                            }
 
                             /* Change to longblob, serves 2 purposes:
                                1. column loses encoding, so when we finally change it to unicode,