summaryrefslogtreecommitdiffstats
path: root/lib/private/files/cache/cache.php
diff options
context:
space:
mode:
Diffstat (limited to 'lib/private/files/cache/cache.php')
-rw-r--r--lib/private/files/cache/cache.php9
1 files changed, 8 insertions, 1 deletions
diff --git a/lib/private/files/cache/cache.php b/lib/private/files/cache/cache.php
index 7ea00325a10..a41ff12ba0e 100644
--- a/lib/private/files/cache/cache.php
+++ b/lib/private/files/cache/cache.php
@@ -266,10 +266,17 @@ class Cache {
}
list($queryParts, $params) = $this->buildParts($data);
+ // duplicate $params because we need the parts twice in the SQL statement
+ // once for the SET part, once in the WHERE clause
+ $params = array_merge($params, $params);
$params[] = $id;
- $sql = 'UPDATE `*PREFIX*filecache` SET ' . implode(' = ?, ', $queryParts) . '=? WHERE `fileid` = ?';
+ // don't update if the data we try to set is the same as the one in the record
+ // some databases (Postgres) don't like superfluous updates
+ $sql = 'UPDATE `*PREFIX*filecache` SET ' . implode(' = ?, ', $queryParts) . '=? ' .
+ 'WHERE (' . implode(' <> ? OR ', $queryParts) . ' <> ? ) AND `fileid` = ? ';
\OC_DB::executeAudited($sql, $params);
+
}
/**