summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMorris Jobke <hey@morrisjobke.de>2015-04-22 13:34:08 +0200
committerMorris Jobke <hey@morrisjobke.de>2015-04-22 13:34:08 +0200
commita971fa8a9057e5c917c6d5634fafd530a6221c07 (patch)
tree01a37c8abfd794d613385f6cbda06bdf6a117e56
parent570718fb6bbad4dfd721b1ef451580749e9e0bdd (diff)
parent9c95315a9eeeb72dbbbe3ae6babba49dffe46386 (diff)
downloadnextcloud-server-a971fa8a9057e5c917c6d5634fafd530a6221c07.tar.gz
nextcloud-server-a971fa8a9057e5c917c6d5634fafd530a6221c07.zip
Merge pull request #15549 from owncloud/jcf-fix-cache-update
don't update identical values
-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 f00177d9c5b..7d3738fdc73 100644
--- a/lib/private/files/cache/cache.php
+++ b/lib/private/files/cache/cache.php
@@ -306,10 +306,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);
+
}
/**