[Pkg-owncloud-commits] [owncloud] 07/10: use insertIfNotExist() in cache put

David Prévot taffit at moszumanska.debian.org
Wed Mar 11 15:50:04 UTC 2015


This is an automated email from the git hooks/post-receive script.

taffit pushed a commit to annotated tag v8.0.2
in repository owncloud.

commit f6ceb0b0d58e00ee4a216b39e377ef1539e55fb9
Author: Thomas Müller <thomas.mueller at tmit.eu>
Date:   Fri Mar 6 15:32:58 2015 +0100

    use insertIfNotExist() in cache put
---
 lib/private/files/cache/cache.php | 16 +++++++++++-----
 1 file changed, 11 insertions(+), 5 deletions(-)

diff --git a/lib/private/files/cache/cache.php b/lib/private/files/cache/cache.php
index 3c097a3..56c9bfa 100644
--- a/lib/private/files/cache/cache.php
+++ b/lib/private/files/cache/cache.php
@@ -240,13 +240,19 @@ class Cache {
 			list($queryParts, $params) = $this->buildParts($data);
 			$queryParts[] = '`storage`';
 			$params[] = $this->getNumericStorageId();
-			$valuesPlaceholder = array_fill(0, count($queryParts), '?');
 
-			$sql = 'INSERT INTO `*PREFIX*filecache` (' . implode(', ', $queryParts) . ')'
-				. ' VALUES (' . implode(', ', $valuesPlaceholder) . ')';
-			\OC_DB::executeAudited($sql, $params);
+			$params = array_map(function($item) {
+				return trim($item, "`");
+			}, $params);
+			$queryParts = array_map(function($item) {
+				return trim($item, "`");
+			}, $queryParts);
+			$values = array_combine($queryParts, $params);
+			if (\OC::$server->getDatabaseConnection()->insertIfNotExist('*PREFIX*filecache', $values)) {
+				return (int)\OC_DB::insertid('*PREFIX*filecache');
+			}
 
-			return (int)\OC_DB::insertid('*PREFIX*filecache');
+			return $this->getId($file);
 		}
 	}
 

-- 
Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/pkg-owncloud/owncloud.git



More information about the Pkg-owncloud-commits mailing list