[TASK] FAL ResourceStorage must not access sys_file table directly 70/23470/4
authorSteffen Ritter <info@rs-websystems.de>
Wed, 11 Sep 2013 15:45:47 +0000 (17:45 +0200)
committerStefan Neufeind <typo3.neufeind@speedpartner.de>
Wed, 11 Sep 2013 15:48:15 +0000 (17:48 +0200)
The ResourceStorage accesses the index table sys_file directly via
a call to the $GLOBALS[TYPO3_DB]. The interaction with the sys_file
index table should be managed only by an according repository to
allow changes within that mechanism.

This patch rearranges the factory method to use the according
call within the FileRepository and adapts it, as the FileRepository
will return a file Object instead of an array.

This serves as a preparation for further indexing optimisations,
which need IndexRecords to be handled centrally.

Releases: 6.2, 6.1, 6.0
Resolves: #51519
Change-Id: I5aa2d212b936b218db1808ea3d0384b8292287a9
Reviewed-on: https://review.typo3.org/23470
Reviewed-by: Stefan Neufeind
Tested-by: Stefan Neufeind
typo3/sysext/core/Classes/Resource/ResourceFactory.php

index 951c488..a0c39f6 100644 (file)
@@ -337,13 +337,17 @@ class ResourceFactory implements \TYPO3\CMS\Core\SingletonInterface {
                if (!$this->fileInstances[$uid]) {
                        // Fetches data in case $fileData is empty
                        if (empty($fileData)) {
-                               /** @var $GLOBALS['TYPO3_DB'] \TYPO3\CMS\Core\Database\DatabaseConnection */
-                               $fileData = $GLOBALS['TYPO3_DB']->exec_SELECTgetSingleRow('*', 'sys_file', 'uid=' . intval($uid));
-                               if (!is_array($fileData)) {
+                               /** @var FileRepository $fileRepository */
+                               $fileRepository = GeneralUtility::makeInstance('TYPO3\CMS\Core\Resource\FileRepository');
+                               $fileObject = $fileRepository->findByUid($uid);
+                               if (!is_object($fileObject)) {
                                        throw new \TYPO3\CMS\Core\Resource\Exception\FileDoesNotExistException('No file found for given UID.', 1317178604);
+                               } else {
+                                       $this->fileInstances[$uid] = $fileObject;
                                }
+                       } else {
+                               $this->fileInstances[$uid] = $this->createFileObject($fileData);
                        }
-                       $this->fileInstances[$uid] = $this->createFileObject($fileData);
                }
                return $this->fileInstances[$uid];
        }
@@ -552,4 +556,4 @@ class ResourceFactory implements \TYPO3\CMS\Core\SingletonInterface {
 }
 
 
-?>
+?>
\ No newline at end of file