[Pkg-owncloud-commits] [owncloud] 54/95: Use insertIfNotExists() and reload mimetypes after inserting one
David Prévot
taffit at moszumanska.debian.org
Wed Mar 11 15:49:49 UTC 2015
This is an automated email from the git hooks/post-receive script.
taffit pushed a commit to annotated tag v8.0.1
in repository owncloud.
commit ee83fa673e6b8467fe22d1ec9a0eba6aa792e651
Author: Joas Schilling <nickvergessen at gmx.de>
Date: Thu Jan 29 15:24:53 2015 +0100
Use insertIfNotExists() and reload mimetypes after inserting one
---
lib/private/files/cache/cache.php | 10 +++++++---
1 file changed, 7 insertions(+), 3 deletions(-)
diff --git a/lib/private/files/cache/cache.php b/lib/private/files/cache/cache.php
index 5438bda..3c097a3 100644
--- a/lib/private/files/cache/cache.php
+++ b/lib/private/files/cache/cache.php
@@ -74,9 +74,11 @@ class Cache {
if (!isset(self::$mimetypeIds[$mime])) {
try {
- $result = \OC_DB::executeAudited('INSERT INTO `*PREFIX*mimetypes`(`mimetype`) VALUES(?)', array($mime));
- self::$mimetypeIds[$mime] = \OC_DB::insertid('*PREFIX*mimetypes');
- self::$mimetypes[self::$mimetypeIds[$mime]] = $mime;
+ $connection = \OC_DB::getConnection();
+ $connection->insertIfNotExist('*PREFIX*mimetypes', [
+ 'mimetype' => $mime,
+ ]);
+ $this->loadMimetypes();
} catch (\Doctrine\DBAL\DBALException $e) {
\OC_Log::write('core', 'Exception during mimetype insertion: ' . $e->getmessage(), \OC_Log::DEBUG);
return -1;
@@ -95,6 +97,8 @@ class Cache {
}
public function loadMimetypes() {
+ self::$mimetypeIds = self::$mimetypes = array();
+
$result = \OC_DB::executeAudited('SELECT `id`, `mimetype` FROM `*PREFIX*mimetypes`', array());
if ($result) {
while ($row = $result->fetchRow()) {
--
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