diff options
author | Morris Jobke <hey@morrisjobke.de> | 2017-05-15 10:56:18 -0500 |
---|---|---|
committer | GitHub <noreply@github.com> | 2017-05-15 10:56:18 -0500 |
commit | 007748fb1e35f83ef2beb48db4f9e0882b90485f (patch) | |
tree | 67c6c1db4892d022248852b8730b9c3fd9cbf6d6 | |
parent | c995bcd557f4ffe8942a3af786e5edd7f2424bd4 (diff) | |
parent | 00ebd5c1846b90f8ad249734abec1f9a7138faaf (diff) | |
download | nextcloud-server-007748fb1e35f83ef2beb48db4f9e0882b90485f.tar.gz nextcloud-server-007748fb1e35f83ef2beb48db4f9e0882b90485f.zip |
Merge pull request #4810 from nextcloud/downstream-27668
Fix mimetype update query
-rw-r--r-- | lib/private/Files/Type/Loader.php | 15 |
1 files changed, 10 insertions, 5 deletions
diff --git a/lib/private/Files/Type/Loader.php b/lib/private/Files/Type/Loader.php index 4dd798e7b07..1ae783e8f83 100644 --- a/lib/private/Files/Type/Loader.php +++ b/lib/private/Files/Type/Loader.php @@ -154,18 +154,23 @@ class Loader implements IMimeTypeLoader { * Update filecache mimetype based on file extension * * @param string $ext file extension - * @param int $mimetypeId + * @param int $mimeTypeId * @return int number of changed rows */ - public function updateFilecache($ext, $mimetypeId) { + public function updateFilecache($ext, $mimeTypeId) { + $folderMimeTypeId = $this->getId('httpd/unix-directory'); $update = $this->dbConnection->getQueryBuilder(); $update->update('filecache') - ->set('mimetype', $update->createNamedParameter($mimetypeId)) + ->set('mimetype', $update->createNamedParameter($mimeTypeId)) ->where($update->expr()->neq( - 'mimetype', $update->createNamedParameter($mimetypeId) + 'mimetype', $update->createNamedParameter($mimeTypeId) + )) + ->andWhere($update->expr()->neq( + 'mimetype', $update->createNamedParameter($folderMimeTypeId) )) ->andWhere($update->expr()->like( - $update->createFunction('LOWER(`name`)'), $update->createNamedParameter($ext) + $update->createFunction('LOWER(' . $update->getColumnName('name') . ')'), + $update->createNamedParameter('%' . $this->dbConnection->escapeLikeParameter('.' . $ext)) )); return $update->execute(); } |