[BUGFIX] inject* methods in FAL inhibit use of Extbase object manager 59/18159/3
authorAndreas Wolf <andreas.wolf@typo3.org>
Sat, 9 Feb 2013 14:49:32 +0000 (15:49 +0100)
committerChristian Kuhn <lolli@schwarzbu.ch>
Wed, 13 Mar 2013 19:05:06 +0000 (20:05 +0100)
The ResourceStorage class of FAL has two inject* methods which are seen
as dependency injectors by the Extbase object manager. Thus an exception
is thrown when a ResourceStorage object is created via Extbase.

This commit changes the two method's names and adjust all usages within
the core. These methods are internal and I don't expect them to be used
anywhere else, so we don't need a backwards compatibility layer.

Change-Id: I4b73445708cf8041b505b5ea8923dc595ddaadb0
Resolves: #45319
Releases: 6.1, 6.0
Reviewed-on: https://review.typo3.org/18159
Reviewed-by: Alexander Opitz
Tested-by: Alexander Opitz
Reviewed-by: Christian Kuhn
Tested-by: Christian Kuhn
t3lib/class.t3lib_userauthgroup.php
typo3/sysext/core/Classes/Authentication/BackendUserAuthentication.php
typo3/sysext/core/Classes/Resource/ResourceStorage.php
typo3/sysext/core/Tests/Unit/Resource/ResourceStorageTest.php

index be698f3..4bab07c 100644 (file)
@@ -1376,11 +1376,11 @@ abstract class t3lib_userAuthGroup extends t3lib_userAuth {
                                        $storageObject = $storageRepository->findByUid($userHomeStorageUid);
                                        // First try and mount with [uid]_[username]
                                        $userHomeFilterIdentifier = $userHomeFilter . $this->user['uid'] . '_' . $this->user['username'] . $GLOBALS['TYPO3_CONF_VARS']['BE']['userUploadDir'];
-                                       $didMount = $storageObject->injectFileMount($userHomeFilterIdentifier);
+                                       $didMount = $storageObject->addFileMount($userHomeFilterIdentifier);
                                        // If that failed, try and mount with only [uid]
                                        if (!$didMount) {
                                                $userHomeFilterIdentifier = $userHomeFilter . $this->user['uid'] . '_' . $this->user['username'] . $GLOBALS['TYPO3_CONF_VARS']['BE']['userUploadDir'];
-                                               $storageObject->injectFileMount($userHomeFilterIdentifier);
+                                               $storageObject->addFileMount($userHomeFilterIdentifier);
                                        }
                                        $this->fileStorages[$storageObject->getUid()] = $storageObject;
                                }
@@ -1394,7 +1394,7 @@ abstract class t3lib_userAuthGroup extends t3lib_userAuth {
                                        $storageObject = $storageRepository->findByUid($groupHomeStorageUid);
                                        foreach ($this->userGroups as $groupUid => $groupData) {
                                                $groupHomeFilterIdentifier = $groupHomeFilter . $groupData['uid'];
-                                               $storageObject->injectFileMount($groupHomeFilterIdentifier);
+                                               $storageObject->addFileMount($groupHomeFilterIdentifier);
                                        }
                                        $this->fileStorages[$storageObject->getUid()] = $storageObject;
                                }
@@ -1406,7 +1406,7 @@ abstract class t3lib_userAuthGroup extends t3lib_userAuth {
                                $res = $GLOBALS['TYPO3_DB']->exec_SELECTquery('*', 'sys_filemounts', 'deleted=0 AND hidden=0 AND pid=0 AND uid IN (' . $this->dataLists['filemount_list'] . ')', '', $orderBy);
                                while ($row = $GLOBALS['TYPO3_DB']->sql_fetch_assoc($res)) {
                                        $storageObject = $storageRepository->findByUid($row['base']);
-                                       $storageObject->injectFileMount($row['path'], $row);
+                                       $storageObject->addFileMount($row['path'], $row);
                                        $this->fileStorages[$storageObject->getUid()] = $storageObject;
                                }
                                $GLOBALS['TYPO3_DB']->sql_free_result($res);
@@ -1415,7 +1415,7 @@ abstract class t3lib_userAuthGroup extends t3lib_userAuth {
                // Injects the users' permissions to each storage
                foreach ($this->fileStorages as $storageObject) {
                        $storagePermissions = $this->getFilePermissionsForStorage($storageObject);
-                       $storageObject->injectUserPermissions($storagePermissions);
+                       $storageObject->setUserPermissions($storagePermissions);
                }
                // more narrowing down through the workspace
                $this->initializeFileStoragesForWorkspace();
@@ -1800,7 +1800,7 @@ abstract class t3lib_userAuthGroup extends t3lib_userAuth {
                                        // TODO: check if the filter is narrowing down the existing user
                                        $storageObject = $storageRepository->findByUid($row['base']);
                                        if (isset($existingFileStoragesOfUser[$storageObject->getUid()])) {
-                                               $storageObject->injectFileMount($row['path']);
+                                               $storageObject->addFileMount($row['path']);
                                                $this->fileStorages[$storageObject->getUid()] = $storageObject;
                                        }
                                }
index 7b992e4..8df53e0 100644 (file)
@@ -1520,11 +1520,11 @@ class BackendUserAuthentication extends \TYPO3\CMS\Core\Authentication\AbstractU
                                        $storageObject = $storageRepository->findByUid($userHomeStorageUid);
                                        // First try and mount with [uid]_[username]
                                        $userHomeFilterIdentifier = $userHomeFilter . $this->user['uid'] . '_' . $this->user['username'] . $GLOBALS['TYPO3_CONF_VARS']['BE']['userUploadDir'];
-                                       $didMount = $storageObject->injectFileMount($userHomeFilterIdentifier);
+                                       $didMount = $storageObject->addFileMount($userHomeFilterIdentifier);
                                        // If that failed, try and mount with only [uid]
                                        if (!$didMount) {
                                                $userHomeFilterIdentifier = $userHomeFilter . $this->user['uid'] . '_' . $this->user['username'] . $GLOBALS['TYPO3_CONF_VARS']['BE']['userUploadDir'];
-                                               $storageObject->injectFileMount($userHomeFilterIdentifier);
+                                               $storageObject->addFileMount($userHomeFilterIdentifier);
                                        }
                                        $this->fileStorages[$storageObject->getUid()] = $storageObject;
                                }
@@ -1538,7 +1538,7 @@ class BackendUserAuthentication extends \TYPO3\CMS\Core\Authentication\AbstractU
                                        $storageObject = $storageRepository->findByUid($groupHomeStorageUid);
                                        foreach ($this->userGroups as $groupUid => $groupData) {
                                                $groupHomeFilterIdentifier = $groupHomeFilter . $groupData['uid'];
-                                               $storageObject->injectFileMount($groupHomeFilterIdentifier);
+                                               $storageObject->addFileMount($groupHomeFilterIdentifier);
                                        }
                                        $this->fileStorages[$storageObject->getUid()] = $storageObject;
                                }
@@ -1550,7 +1550,7 @@ class BackendUserAuthentication extends \TYPO3\CMS\Core\Authentication\AbstractU
                                $res = $GLOBALS['TYPO3_DB']->exec_SELECTquery('*', 'sys_filemounts', 'deleted=0 AND hidden=0 AND pid=0 AND uid IN (' . $this->dataLists['filemount_list'] . ')', '', $orderBy);
                                while ($row = $GLOBALS['TYPO3_DB']->sql_fetch_assoc($res)) {
                                        $storageObject = $storageRepository->findByUid($row['base']);
-                                       $storageObject->injectFileMount($row['path'], $row);
+                                       $storageObject->addFileMount($row['path'], $row);
                                        $this->fileStorages[$storageObject->getUid()] = $storageObject;
                                }
                                $GLOBALS['TYPO3_DB']->sql_free_result($res);
@@ -1559,7 +1559,7 @@ class BackendUserAuthentication extends \TYPO3\CMS\Core\Authentication\AbstractU
                // Injects the users' permissions to each storage
                foreach ($this->fileStorages as $storageObject) {
                        $storagePermissions = $this->getFilePermissionsForStorage($storageObject);
-                       $storageObject->injectUserPermissions($storagePermissions);
+                       $storageObject->setUserPermissions($storagePermissions);
                }
                // more narrowing down through the workspace
                $this->initializeFileStoragesForWorkspace();
@@ -1940,7 +1940,7 @@ class BackendUserAuthentication extends \TYPO3\CMS\Core\Authentication\AbstractU
                                        // TODO: check if the filter is narrowing down the existing user
                                        $storageObject = $storageRepository->findByUid($row['base']);
                                        if (isset($existingFileStoragesOfUser[$storageObject->getUid()])) {
-                                               $storageObject->injectFileMount($row['path']);
+                                               $storageObject->addFileMount($row['path']);
                                                $this->fileStorages[$storageObject->getUid()] = $storageObject;
                                        }
                                }
@@ -2458,4 +2458,4 @@ This is a dump of the failures:
 }
 
 
-?>
\ No newline at end of file
+?>
index 75c8860..6fe46d9 100644 (file)
@@ -459,7 +459,7 @@ class ResourceStorage {
         * @throws Exception\FolderDoesNotExistException
         * @return void
         */
-       public function injectFileMount($folderIdentifier, $additionalData = array()) {
+       public function addFileMount($folderIdentifier, $additionalData = array()) {
                // check for the folder before we add it as a filemount
                if ($this->driver->folderExists($folderIdentifier) === FALSE) {
                        // if there is an error, this is important and should be handled
@@ -525,12 +525,12 @@ class ResourceStorage {
        }
 
        /**
-        * Adds user permissions to the storage
+        * Sets the user permissions of the storage
         *
         * @param array $userPermissions
         * @return void
         */
-       public function injectUserPermissions(array $userPermissions) {
+       public function setUserPermissions(array $userPermissions) {
                $this->userPermissions = $userPermissions;
        }
 
@@ -2001,4 +2001,4 @@ class ResourceStorage {
        }
 }
 
-?>
\ No newline at end of file
+?>
index 9c41ea4..0bc2c71 100644 (file)
@@ -334,7 +334,7 @@ class ResourceStorageTest extends \TYPO3\CMS\Core\Tests\Unit\Resource\BaseTestCa
         */
        public function checkUserActionPermissionReturnsFalseIfPermissionIsSetToZero() {
                $this->prepareFixture(array());
-               $this->fixture->injectUserPermissions(array('readFolder' => TRUE, 'writeFile' => TRUE));
+               $this->fixture->setUserPermissions(array('readFolder' => TRUE, 'writeFile' => TRUE));
                $this->assertTrue($this->fixture->checkUserActionPermission('read', 'folder'));
        }
 
@@ -364,7 +364,7 @@ class ResourceStorageTest extends \TYPO3\CMS\Core\Tests\Unit\Resource\BaseTestCa
         */
        public function checkUserActionPermissionAcceptsArbitrarilyCasedArguments($permissions, $action, $type) {
                $this->prepareFixture(array());
-               $this->fixture->injectUserPermissions($permissions);
+               $this->fixture->setUserPermissions($permissions);
                $this->assertTrue($this->fixture->checkUserActionPermission($action, $type));
        }
 
@@ -373,7 +373,7 @@ class ResourceStorageTest extends \TYPO3\CMS\Core\Tests\Unit\Resource\BaseTestCa
         */
        public function userActionIsDisallowedIfPermissionIsSetToFalse() {
                $this->prepareFixture(array());
-               $this->fixture->injectUserPermissions(array('readFolder' => FALSE));
+               $this->fixture->setUserPermissions(array('readFolder' => FALSE));
                $this->assertFalse($this->fixture->checkUserActionPermission('read', 'folder'));
        }
 
@@ -382,7 +382,7 @@ class ResourceStorageTest extends \TYPO3\CMS\Core\Tests\Unit\Resource\BaseTestCa
         */
        public function userActionIsDisallowedIfPermissionIsNotSet() {
                $this->prepareFixture(array());
-               $this->fixture->injectUserPermissions(array('readFolder' => TRUE));
+               $this->fixture->setUserPermissions(array('readFolder' => TRUE));
                $this->assertFalse($this->fixture->checkUserActionPermission('write', 'folder'));
        }
 
@@ -476,7 +476,7 @@ class ResourceStorageTest extends \TYPO3\CMS\Core\Tests\Unit\Resource\BaseTestCa
                $mockedDriver = $this->createDriverMock(array('basePath' => $this->getMountRootUrl()), NULL, NULL);
                $this->initializeVfs();
                $this->prepareFixture(array(), NULL, $mockedDriver);
-               $this->fixture->injectFileMount('/mountFolder');
+               $this->fixture->addFileMount('/mountFolder');
                $this->assertEquals(1, count($this->fixture->getFileMounts()));
                $this->fixture->isWithinFileMountBoundaries($mockedFile);
        }
@@ -649,4 +649,4 @@ class ResourceStorageTest extends \TYPO3\CMS\Core\Tests\Unit\Resource\BaseTestCa
 
 }
 
-?>
\ No newline at end of file
+?>