diff options
author | Vincent Petry <pvince81@owncloud.com> | 2015-05-15 18:22:49 +0200 |
---|---|---|
committer | Vincent Petry <pvince81@owncloud.com> | 2015-05-15 18:22:49 +0200 |
commit | 1d35c01b19ad70982c75cd76d0901485848cf8c4 (patch) | |
tree | a581d361dfe83a19b9f6cccc3036cd038e1c1de5 | |
parent | 15c85014838a734b18c7ef24352298b9bfbd7d41 (diff) | |
parent | c668a7c66547809158977be754c601984af4bb2f (diff) | |
download | nextcloud-server-1d35c01b19ad70982c75cd76d0901485848cf8c4.tar.gz nextcloud-server-1d35c01b19ad70982c75cd76d0901485848cf8c4.zip |
Merge pull request #15974 from owncloud/backport-15549
[stable8] don't update identical values
-rw-r--r-- | lib/private/files/cache/cache.php | 9 |
1 files changed, 8 insertions, 1 deletions
diff --git a/lib/private/files/cache/cache.php b/lib/private/files/cache/cache.php index e9ed987a6ff..358e654aada 100644 --- a/lib/private/files/cache/cache.php +++ b/lib/private/files/cache/cache.php @@ -285,10 +285,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); + } /** |