Permalink
Browse files

stricter checking of null fields when restoring HotPots in order to a…

…void unwanted chars being inserted into empty char fields on PostgreSQL sites
  • Loading branch information...
gbateson
gbateson committed Sep 25, 2009
1 parent d5e0549 commit 5934fe5d9434378cdc30b693b0d711f33331a08a
Showing with 8 additions and 11 deletions.
  1. +8 −11 mod/hotpot/restorelib.php
View
@@ -362,17 +362,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('/int|decimal|double|float|time|year/i', $column->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('/int|decimal|double|float|time|year/i', $column->type)) {
+ $record->$name = 0;
+ } else {
+ $record->$name = '';
}
}
}

0 comments on commit 5934fe5

Please sign in to comment.