Commit a7d345d7 authored by Dries's avatar Dries

- Patch #200824 by sammys, Arancaytar et al: fixed bug in drupal_write_record().

parent 75a777a3
......@@ -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);
}
}
}
else {
$return = FALSE;
}
// If we began with an array, convert back so we don't surprise the caller.
if ($array) {
$object = (array) $object;
}
return $return;
// If we began with an array, convert back so we don't surprise the caller.
if ($array) {
$object = (array) $object;
}
return FALSE;
return $return;
}
/**
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment