Merge pull request #4913 from nextcloud/backport-4810-mimetype-update

[stable11] Fix mimetype update query
This commit is contained in:
Morris Jobke 2017-06-13 17:39:31 -05:00 committed by GitHub
commit f6181d8e16
1 changed files with 10 additions and 5 deletions

View File

@ -155,18 +155,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();
}