[BUGFIX] Files contents cannot be changed
authorAndreas Wolf <andreas.wolf@typo3.org>
Sat, 1 Sep 2012 13:35:44 +0000 (15:35 +0200)
committerHelmut Hummel <helmut.hummel@typo3.org>
Sun, 16 Sep 2012 14:02:15 +0000 (16:02 +0200)
Setting file contents failed for two reasons:

a) The permissions were incorrectly read from TSconfig and

b) We used a new "update" permission that was not present
   in the default configuration, so without manually setting it,
   a file could never be updated, even by admins.

This commit changes the "update" permission back to "edit", which was
also used in the pre-FAL era.

Change-Id: I408a19257a50868f7978ffac32eefbd410117e2d
Resolves: #37812
Resolves: #39860
Resolves: #39949
Releases: 6.0
Reviewed-on: http://review.typo3.org/14257
Reviewed-by: Helmut Hummel
Tested-by: Helmut Hummel
typo3/sysext/core/Classes/Authentication/BackendUserAuthentication.php
typo3/sysext/core/Classes/Resource/ResourceStorage.php

index f1c52f1..551906e 100644 (file)
@@ -1714,7 +1714,8 @@ class BackendUserAuthentication extends \TYPO3\CMS\Core\Authentication\AbstractU
         */
        public function getFilePermissionsForStorage(\TYPO3\CMS\Core\Resource\ResourceStorage $storageObject) {
                $defaultFilePermissions = $this->getFilePermissions();
-               $storageFilePermissions = $this->getTSConfig('permissions.file.storage.' . $storageObject->getUid());
+               $storagePermissionsArray = $this->getTSConfig('permissions.file.storage.' . $storageObject->getUid());
+               $storageFilePermissions = $storagePermissionsArray['properties'];
                if (is_array($storageFilePermissions) && count($storageFilePermissions)) {
                        return array_merge($storageFilePermissions, $defaultFilePermissions);
                } else {
index 119a45d..a055d63 100644 (file)
@@ -920,17 +920,20 @@ class ResourceStorage {
         * @param \TYPO3\CMS\Core\Resource\AbstractFile $file
         * @param string $contents
         * @return integer The number of bytes written to the file
+        * @throws \RuntimeException
+        * @throws Exception\InsufficientFileWritePermissionsException
+        * @throws Exception\InsufficientUserPermissionsException
         */
        public function setFileContents(\TYPO3\CMS\Core\Resource\AbstractFile $file, $contents) {
-               // Check if user is allowed to update
-               if (!$this->checkUserActionPermission('update', 'File')) {
-                       throw new \TYPO3\CMS\Core\Resource\Exception\InsufficientUserPermissionsException('Updating file "' . $file->getIdentifier() . '" not allowed for user.', 1330121117);
+                       // Check if user is allowed to edit
+               if (!$this->checkUserActionPermission('edit', 'File')) {
+                       throw new Exception\InsufficientUserPermissionsException(('Updating file "' . $file->getIdentifier()) . '" not allowed for user.', 1330121117);
                }
-               // Check if $file is writable
+                       // Check if $file is writable
                if (!$this->checkFileActionPermission('write', $file)) {
-                       throw new \TYPO3\CMS\Core\Resource\Exception\InsufficientFileWritePermissionsException('Writing to file "' . $file->getIdentifier() . '" is not allowed.', 1330121088);
+                       throw new Exception\InsufficientFileWritePermissionsException('Writing to file "' . $file->getIdentifier() . '" is not allowed.', 1330121088);
                }
-               // Call driver method to update the file and update file properties afterwards
+                       // Call driver method to update the file and update file properties afterwards
                try {
                        $result = $this->driver->setFileContents($file, $contents);
                        $fileInfo = $this->driver->getFileInfo($file);
@@ -1153,7 +1156,6 @@ class ResourceStorage {
                        'crdate' => $fileInfo['ctime'],
                        'mime_type' => $fileInfo['mimetype'],
                        'size' => $fileInfo['size'],
-                       'tstamp' => $fileInfo['mtime'],
                        'name' => $fileInfo['name']
                );
                if ($storage !== NULL) {