Skip to content

Commit

Permalink
stricter checking of null fields when restoring HotPots in order to a…
Browse files Browse the repository at this point in the history
…void unwanted chars being inserted into empty char fields on PostgreSQL sites
  • Loading branch information
gbateson committed Sep 25, 2009
1 parent cc1575f commit 668bcd5
Showing 1 changed file with 8 additions and 11 deletions.
19 changes: 8 additions & 11 deletions mod/hotpot/restorelib.php
Expand Up @@ -362,17 +362,14 @@ function hotpot_restore_record(&$restore, $status, &$xml, $table, $foreign_keys,
foreach ($table_columns[$table] as $column) { foreach ($table_columns[$table] as $column) {
if ($column->not_null) { if ($column->not_null) {
$name = $column->name; $name = $column->name;
if ($name<>'id' && empty($record->$name)) { if ($name=='id' || (isset($record->$name) && ! is_null($record->$name))) {
if (isset($column->default_value)) { // do nothing
$default = $column->default_value; } else if (isset($column->default_value)) {
} else { $record->$name = $column->default_value;
if (preg_match('/int|decimal|double|float|time|year/i', $column->type)) { } else if (preg_match('/int|decimal|double|float|time|year/i', $column->type)) {
$default = 0; $record->$name = 0;
} else { } else {
$default = ''; $record->$name = '';
}
}
$record->$name = $default;
} }
} }
} }
Expand Down

0 comments on commit 668bcd5

Please sign in to comment.