- Patch #200824 by sammys, Arancaytar et al: fixed bug in drupal_write_record().
parent
75a777a3ea
commit
a7d345d7a7
|
@ -3232,6 +3232,11 @@ function drupal_write_record($table, &$object, $update = array()) {
|
|||
$update = array($update);
|
||||
}
|
||||
|
||||
$schema = drupal_get_schema($table);
|
||||
if (empty($schema)) {
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
// Convert to an object if needed.
|
||||
if (is_array($object)) {
|
||||
$object = (object) $object;
|
||||
|
@ -3241,11 +3246,6 @@ function drupal_write_record($table, &$object, $update = array()) {
|
|||
$array = FALSE;
|
||||
}
|
||||
|
||||
$schema = drupal_get_schema($table);
|
||||
if (empty($schema)) {
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
$fields = $defs = $values = $serials = $placeholders = array();
|
||||
|
||||
// Go through our schema, build SQL, and when inserting, fill in defaults for
|
||||
|
@ -3326,16 +3326,17 @@ function drupal_write_record($table, &$object, $update = array()) {
|
|||
$object->$field = db_last_insert_id($table, $field);
|
||||
}
|
||||
}
|
||||
|
||||
// If we began with an array, convert back so we don't surprise the caller.
|
||||
if ($array) {
|
||||
$object = (array) $object;
|
||||
}
|
||||
|
||||
return $return;
|
||||
}
|
||||
else {
|
||||
$return = FALSE;
|
||||
}
|
||||
|
||||
return FALSE;
|
||||
// If we began with an array, convert back so we don't surprise the caller.
|
||||
if ($array) {
|
||||
$object = (array) $object;
|
||||
}
|
||||
|
||||
return $return;
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
Loading…
Reference in New Issue