From f1ef5fc5379f9acad16f412648ff44e9266805c1 Mon Sep 17 00:00:00 2001 From: Rello Date: Tue, 18 Apr 2017 21:41:52 +0200 Subject: [PATCH 1/4] =?UTF-8?q?don=C2=B4t=20change=20folders=20with=20--re?= =?UTF-8?q?pair-filecache?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit check if folder is "httpd/unix-directory" and donĀ“t perform here #27585 --- lib/private/Files/Type/Loader.php | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/lib/private/Files/Type/Loader.php b/lib/private/Files/Type/Loader.php index 4dd798e7b0..bc3c2f1c9e 100644 --- a/lib/private/Files/Type/Loader.php +++ b/lib/private/Files/Type/Loader.php @@ -158,12 +158,16 @@ class Loader implements IMimeTypeLoader { * @return int number of changed rows */ public function updateFilecache($ext, $mimetypeId) { + $is_folderId = $this->getId('httpd/unix-directory'); $update = $this->dbConnection->getQueryBuilder(); $update->update('filecache') ->set('mimetype', $update->createNamedParameter($mimetypeId)) ->where($update->expr()->neq( 'mimetype', $update->createNamedParameter($mimetypeId) )) + ->andwhere($update->expr()->neq( + 'mimetype', $update->createNamedParameter($is_folderId) + )) ->andWhere($update->expr()->like( $update->createFunction('LOWER(`name`)'), $update->createNamedParameter($ext) )); From 65efb388e660dbb10b73e622dd776a8ee8618f1d Mon Sep 17 00:00:00 2001 From: Joas Schilling Date: Thu, 11 May 2017 10:57:20 +0200 Subject: [PATCH 2/4] Actually we want to update the mimetype of all files ending with the suffix Signed-off-by: Joas Schilling --- lib/private/Files/Type/Loader.php | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/lib/private/Files/Type/Loader.php b/lib/private/Files/Type/Loader.php index bc3c2f1c9e..4109368909 100644 --- a/lib/private/Files/Type/Loader.php +++ b/lib/private/Files/Type/Loader.php @@ -158,7 +158,7 @@ class Loader implements IMimeTypeLoader { * @return int number of changed rows */ public function updateFilecache($ext, $mimetypeId) { - $is_folderId = $this->getId('httpd/unix-directory'); + $isFolderId = $this->getId('httpd/unix-directory'); $update = $this->dbConnection->getQueryBuilder(); $update->update('filecache') ->set('mimetype', $update->createNamedParameter($mimetypeId)) @@ -166,10 +166,11 @@ class Loader implements IMimeTypeLoader { 'mimetype', $update->createNamedParameter($mimetypeId) )) ->andwhere($update->expr()->neq( - 'mimetype', $update->createNamedParameter($is_folderId) + 'mimetype', $update->createNamedParameter($isFolderId) )) ->andWhere($update->expr()->like( - $update->createFunction('LOWER(`name`)'), $update->createNamedParameter($ext) + $update->createFunction('LOWER(' . $update->getColumnName('name') . ')'), + '%' . $this->dbConnection->escapeLikeParameter($update->createNamedParameter('.' . $ext)) )); return $update->execute(); } From fd75c082386444ff5f9a61853cf493597c2bea28 Mon Sep 17 00:00:00 2001 From: Joas Schilling Date: Fri, 12 May 2017 09:33:51 +0200 Subject: [PATCH 3/4] Fix order of parameter and escaping Signed-off-by: Joas Schilling --- lib/private/Files/Type/Loader.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/lib/private/Files/Type/Loader.php b/lib/private/Files/Type/Loader.php index 4109368909..1217e0dd49 100644 --- a/lib/private/Files/Type/Loader.php +++ b/lib/private/Files/Type/Loader.php @@ -165,12 +165,12 @@ class Loader implements IMimeTypeLoader { ->where($update->expr()->neq( 'mimetype', $update->createNamedParameter($mimetypeId) )) - ->andwhere($update->expr()->neq( + ->andWhere($update->expr()->neq( 'mimetype', $update->createNamedParameter($isFolderId) )) ->andWhere($update->expr()->like( $update->createFunction('LOWER(' . $update->getColumnName('name') . ')'), - '%' . $this->dbConnection->escapeLikeParameter($update->createNamedParameter('.' . $ext)) + $update->createNamedParameter('%' . $this->dbConnection->escapeLikeParameter('.' . $ext)) )); return $update->execute(); } From 00ebd5c1846b90f8ad249734abec1f9a7138faaf Mon Sep 17 00:00:00 2001 From: Joas Schilling Date: Mon, 15 May 2017 12:38:30 +0200 Subject: [PATCH 4/4] Fix variable names Signed-off-by: Joas Schilling --- lib/private/Files/Type/Loader.php | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/lib/private/Files/Type/Loader.php b/lib/private/Files/Type/Loader.php index 1217e0dd49..1ae783e8f8 100644 --- a/lib/private/Files/Type/Loader.php +++ b/lib/private/Files/Type/Loader.php @@ -154,19 +154,19 @@ 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) { - $isFolderId = $this->getId('httpd/unix-directory'); + 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($isFolderId) + 'mimetype', $update->createNamedParameter($folderMimeTypeId) )) ->andWhere($update->expr()->like( $update->createFunction('LOWER(' . $update->getColumnName('name') . ')'),