]> git.mjollnir.org Git - moodle.git/commitdiff
stricter checking of null fields when restoring HotPots in order to avoid unwanted...
authorgbateson <gbateson>
Fri, 25 Sep 2009 06:21:28 +0000 (06:21 +0000)
committergbateson <gbateson>
Fri, 25 Sep 2009 06:21:28 +0000 (06:21 +0000)
mod/hotpot/restorelib.php

index 6a1aa8c49bee2c848ea00cdc7e93a25ad29422a0..966082d3306b1b80e29ff217aa6a99c56c2a4233 100644 (file)
@@ -366,17 +366,14 @@ function hotpot_restore_record(&$restore, $status, &$xml, $table, $foreign_keys,
     foreach ($table_columns[$table] as $column) {
         if ($column->not_null) {
             $name = $column->name;
-            if ($name<>'id' && empty($record->$name)) {
-                if (isset($column->default_value)) {
-                    $default = $column->default_value;
-                } else {
-                    if (preg_match('/[INTD]/', $column->meta_type)) {
-                        $default = 0;
-                    } else {
-                        $default = '';
-                    }
-                }
-                $record->$name = $default;
+            if ($name=='id' || (isset($record->$name) && ! is_null($record->$name))) {
+                // do nothing
+            } else if (isset($column->default_value)) {
+                $record->$name = $column->default_value;
+            } else if (preg_match('/[INTD]/', $column->meta_type)) {
+                $record->$name = 0;
+            } else {
+                $record->$name = '';
             }
         }
     }