summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--includes/common.inc25
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;
}
/**