From eb619ab258ad980625eae32cfd040dae4e990518 Mon Sep 17 00:00:00 2001
From: Alexander Stehlik <alexander.stehlik@googlemail.com>
Date: Wed, 5 Feb 2014 17:05:09 +0100
Subject: [PATCH] [BUGFIX] Update file type on mimetype change
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit

If the mime type of a file has changed, the type property of a file
will be updated, too.

Resolves: #54305
Releases: 6.2
Change-Id: I013e2adbbb3d3cd3973ab50c8e88806b9477fe90
Reviewed-on: https://review.typo3.org/26288
Reviewed-by: Markus Klein
Reviewed-by: Marcin SÄ…gol
Reviewed-by: Steffen Ritter
Tested-by: Markus Klein
Tested-by: Steffen Ritter
---
 typo3/sysext/core/Classes/Resource/File.php | 7 ++++++-
 1 file changed, 6 insertions(+), 1 deletion(-)

diff --git a/typo3/sysext/core/Classes/Resource/File.php b/typo3/sysext/core/Classes/Resource/File.php
index 114b0d7217cf..ab5b6b0678ba 100644
--- a/typo3/sysext/core/Classes/Resource/File.php
+++ b/typo3/sysext/core/Classes/Resource/File.php
@@ -244,7 +244,12 @@ class File extends AbstractFile {
 				$this->properties[$key] = $value;
 			}
 		}
-
+		// If the mime_type property should be updated and it was changed also update the type.
+		if (array_key_exists('mime_type', $properties) && in_array('mime_type', $this->updatedProperties)) {
+			$this->updatedProperties[] = 'type';
+			unset($this->properties['type']);
+			$this->getType();
+		}
 		if (array_key_exists('storage', $properties) && in_array('storage', $this->updatedProperties)) {
 			$this->storage = ResourceFactory::getInstance()->getStorageObject($properties['storage']);
 		}
-- 
GitLab