diff options
author | Dries Buytaert <dries@buytaert.net> | 2008-05-15 21:15:10 +0000 |
---|---|---|
committer | Dries Buytaert <dries@buytaert.net> | 2008-05-15 21:15:10 +0000 |
commit | a7d345d7a70de3e5fd596bfeef3d8300574b211c (patch) | |
tree | d86e2d039efda4090d44f6c93c21b1b07cd7b5f7 | |
parent | 75a777a3ea3e6c9c6ab1f8508dfe8feffe5da88d (diff) | |
download | brdo-a7d345d7a70de3e5fd596bfeef3d8300574b211c.tar.gz brdo-a7d345d7a70de3e5fd596bfeef3d8300574b211c.tar.bz2 |
- Patch #200824 by sammys, Arancaytar et al: fixed bug in drupal_write_record().
-rw-r--r-- | includes/common.inc | 25 |
1 files changed, 13 insertions, 12 deletions
diff --git a/includes/common.inc b/includes/common.inc index 046e1bd50..fdb51571a 100644 --- a/includes/common.inc +++ b/includes/common.inc @@ -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; } /** |