[BUGFIX] Update file type on mimetype change 88/26288/6
authorAlexander Stehlik <alexander.stehlik@googlemail.com>
Wed, 5 Feb 2014 16:05:09 +0000 (17:05 +0100)
committerSteffen Ritter <info@rs-websystems.de>
Fri, 21 Feb 2014 07:51:28 +0000 (08:51 +0100)
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

index 114b0d7..ab5b6b0 100644 (file)
@@ -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']);
                }