From ff41ee40bf365c4ec043ad7ff70c9c63f3100239 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 d1f447d808..357747848a 100644 --- a/lib/private/Files/Type/Loader.php +++ b/lib/private/Files/Type/Loader.php @@ -159,12 +159,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 c85a770ecfb3e0824b777aff4e938765e188f561 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 357747848a..9dcd21b4d9 100644 --- a/lib/private/Files/Type/Loader.php +++ b/lib/private/Files/Type/Loader.php @@ -159,7 +159,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)) @@ -167,10 +167,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 2e3fe61f992ed2afae7cc9037039e931de8794b3 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 9dcd21b4d9..f338c4314d 100644 --- a/lib/private/Files/Type/Loader.php +++ b/lib/private/Files/Type/Loader.php @@ -166,12 +166,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 59f621e9cdd82c2a606fc6ae7ec8d3509ef39000 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 f338c4314d..2263aa2ae0 100644 --- a/lib/private/Files/Type/Loader.php +++ b/lib/private/Files/Type/Loader.php @@ -155,19 +155,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') . ')'),