From e60d38c7813a24759c4cc63b7394852da3e796a0 Mon Sep 17 00:00:00 2001 From: Dries Buytaert Date: Mon, 9 Aug 2010 00:13:06 +0000 Subject: - Patch #797680 by lyricnz, jbrown: drupal_write_record() unnecessarily sets primary keys while updating. --- includes/common.inc | 6 ++++++ includes/path.inc | 2 +- 2 files changed, 7 insertions(+), 1 deletion(-) (limited to 'includes') 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) { -- cgit v1.2.3