Skip to content

Commit

Permalink
Merge pull request #4913 from nextcloud/backport-4810-mimetype-update
Browse files Browse the repository at this point in the history
[stable11] Fix mimetype update query
  • Loading branch information
MorrisJobke committed Jun 13, 2017
2 parents 136601c + 59f621e commit f6181d8
Showing 1 changed file with 10 additions and 5 deletions.
15 changes: 10 additions & 5 deletions lib/private/Files/Type/Loader.php
Original file line number Diff line number Diff line change
Expand Up @@ -155,18 +155,23 @@ private function loadMimetypes() {
* 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();
}
Expand Down

0 comments on commit f6181d8

Please sign in to comment.