diff options
author | Dries Buytaert <dries@buytaert.net> | 2010-08-09 00:13:06 +0000 |
---|---|---|
committer | Dries Buytaert <dries@buytaert.net> | 2010-08-09 00:13:06 +0000 |
commit | e60d38c7813a24759c4cc63b7394852da3e796a0 (patch) | |
tree | 62d91b0d92e7eb7736c8ec67c986dcbd338637be | |
parent | 786ba6e88ab947142bd6d0136ed9cd590f1ecfe9 (diff) | |
download | brdo-e60d38c7813a24759c4cc63b7394852da3e796a0.tar.gz brdo-e60d38c7813a24759c4cc63b7394852da3e796a0.tar.bz2 |
- Patch #797680 by lyricnz, jbrown: drupal_write_record() unnecessarily sets primary keys while updating.
-rw-r--r-- | includes/common.inc | 6 | ||||
-rw-r--r-- | includes/path.inc | 2 |
2 files changed, 7 insertions, 1 deletions
diff --git a/includes/common.inc b/includes/common.inc index 220414a2d..be7c72234 100644 --- a/includes/common.inc +++ b/includes/common.inc @@ -5955,6 +5955,12 @@ function drupal_write_record($table, &$record, $primary_keys = array()) { $serial = $field; } + // Skip field if it is in $primary_keys as it is unnecessary to update a + // field to the value it is already set to. + if (in_array($field, $primary_keys)) { + continue; + } + if (!property_exists($object, $field)) { // Skip fields that are not provided, default values are already known // by the database. diff --git a/includes/path.inc b/includes/path.inc index ac78b0a74..3b5549656 100644 --- a/includes/path.inc +++ b/includes/path.inc @@ -397,7 +397,7 @@ function path_save(&$path) { $path += array('pid' => NULL, 'language' => LANGUAGE_NONE); // Insert or update the alias. - $status = drupal_write_record('url_alias', $path, (!empty($path['pid']) ? 'pid' : NULL)); + $status = drupal_write_record('url_alias', $path, (!empty($path['pid']) ? 'pid' : array())); // Verify that a record was written. if ($status) { |