[TASK] Use the new FAL Indexer 71/25371/5
authorSteffen Ritter <info@rs-websystems.de>
Wed, 13 Nov 2013 12:12:29 +0000 (13:12 +0100)
committerErnesto Baschny <ernst@cron-it.de>
Sat, 16 Nov 2013 02:34:13 +0000 (03:34 +0100)
This patch-set uses the new Indexer for FAL.

See: http://wiki.typo3.org/Blueprints/FAL-IndexerRework

Releases: 6.2
Resolves: #53600
Change-Id: Ibfbb42358a69ba1b7bd90e5643a104b1b6521ff8
Reviewed-on: https://review.typo3.org/25371
Reviewed-by: Ernesto Baschny
Tested-by: Ernesto Baschny
typo3/sysext/core/Classes/Resource/File.php
typo3/sysext/core/Classes/Resource/ResourceFactory.php
typo3/sysext/core/Classes/Resource/Service/IndexerService.php
typo3/sysext/core/Classes/Utility/File/ExtendedFileUtility.php

index 8fbac8b..d3832ac 100644 (file)
@@ -190,11 +190,8 @@ class File extends AbstractFile {
 
                $indexRecord = $this->getFileIndexRepository()->findOneByCombinedIdentifier($this->getCombinedIdentifier());
                if ($indexRecord === FALSE && $indexIfNotIndexed) {
-                       // the IndexerService is not used at this place since, its not about additional MetaData anymore
-                       $indexRecord = $this->getIndexerService()->indexFile($this, FALSE);
-                       $this->mergeIndexRecord($indexRecord);
-                       $this->indexed = TRUE;
-                       $this->loadMetaData();
+                       $this->getIndexerService()->updateIndexEntry($this);
+                       $this->updatedProperties = array();
                } elseif ($indexRecord !== FALSE) {
                        $this->mergeIndexRecord($indexRecord);
                        $this->indexed = TRUE;
@@ -422,11 +419,11 @@ class File extends AbstractFile {
         * Internal function to retrieve the indexer service,
         * if it does not exist, an instance will be created
         *
-        * @return Service\IndexerService
+        * @return Index\Indexer
         */
        protected function getIndexerService() {
                if ($this->indexerService === NULL) {
-                       $this->indexerService = \TYPO3\CMS\Core\Utility\GeneralUtility::makeInstance('TYPO3\\CMS\\Core\\Resource\\Service\\IndexerService');
+                       $this->indexerService = \TYPO3\CMS\Core\Utility\GeneralUtility::makeInstance('TYPO3\\CMS\\Core\\Resource\\Index\\Indexer', $this->storage);
                }
                return $this->indexerService;
        }
index 549a57f..986c6d3 100644 (file)
@@ -385,18 +385,14 @@ class ResourceFactory implements \TYPO3\CMS\Core\SingletonInterface {
        public function getFileObjectByStorageAndIdentifier($storageUid, &$fileIdentifier) {
                $storage = $this->getStorageObject($storageUid, array(), $fileIdentifier);
                $fileData = $this->getFileIndexRepository()->findOneByStorageUidAndIdentifier($storage->getUid(), $fileIdentifier);
-               if ($fileData !== FALSE) {
-                       $fileObject = $this->getFileObject($fileData['uid'], $fileData);
+               if ($fileData === FALSE) {
+                       $fileObject = $this->getIndexer($storage)->createIndexEntry($fileIdentifier);
                } else {
-                       $fileData = $storage->getFileInfoByIdentifier($fileIdentifier);
-                       $fileObject = $this->createFileObject($fileData, $storage);
-                       if (!array_key_exists('uid', $fileData)) {
-                               $this->getFileIndexRepository()->add($fileObject);
-                       }
-                       $this->fileInstances[$fileObject->getUid()] = $fileObject;
+                       $fileObject = $this->getFileObject($fileData['uid'], $fileData);
                }
                return $fileObject;
        }
+
        /**
         * Bulk function, can be used for anything to get a file or folder
         *
@@ -591,4 +587,14 @@ class ResourceFactory implements \TYPO3\CMS\Core\SingletonInterface {
        protected function getFileIndexRepository() {
                return FileIndexRepository::getInstance();
        }
+
+       /**
+        * Returns an instance of the Indexer
+        *
+        * @return \TYPO3\CMS\Core\Resource\Index\Indexer
+        */
+       protected function getIndexer(ResourceStorage $storage) {
+               return GeneralUtility::makeInstance('TYPO3\\CMS\\Core\\Resource\\Index\\Indexer', $storage);
+       }
+
 }
index 402fc5c..604edaf 100644 (file)
@@ -35,6 +35,7 @@ use TYPO3\CMS\Core\Utility\GeneralUtility;
  * should only be accessed through the FileRepository for now
  *
  * @author Andreas Wolf <andreas.wolf@ikt-werk.de>
+ * @deprecated since TYPO3 CMS 6.2 LTS - will be removed 2 versions later
  */
 class IndexerService implements \TYPO3\CMS\Core\SingletonInterface {
 
index 6d2c437..e1905b0 100644 (file)
@@ -75,11 +75,6 @@ class ExtendedFileUtility extends \TYPO3\CMS\Core\Utility\File\BasicFileUtility
         */
        public $dontCheckForUnique = 0;
 
-       /**
-        * @var \TYPO3\CMS\Core\Resource\Service\IndexerService
-        */
-       protected $indexerService = NULL;
-
        /**
         * This array is self-explaining (look in the class below).
         * It grants access to the functions. This could be set from outside in order to enabled functions to users.
@@ -924,7 +919,10 @@ class ExtendedFileUtility extends \TYPO3\CMS\Core\Utility\File\BasicFileUtility
                                }
                                /** @var $fileObject File */
                                $fileObject = $targetFolderObject->addUploadedFile($fileInfo, $conflictMode);
-                               $fileObject = $this->getIndexerService()->indexFile($fileObject);
+                               $fileObject = \TYPO3\CMS\Core\Resource\ResourceFactory::getInstance()->getFileObjectByStorageAndIdentifier($targetFolderObject->getStorage()->getUid(), $fileObject->getIdentifier());
+                               if ($conflictMode === 'replace') {
+                                       $this->getIndexer($fileObject->getStorage())->updateIndexEntry($fileObject);
+                               }
                                $resultObjects[] = $fileObject;
                                $this->writelog(1, 0, 1, 'Uploading file "%s" to "%s"', array($fileInfo['name'], $targetFolderObject->getIdentifier()));
                        } catch (\TYPO3\CMS\Core\Resource\Exception\UploadException $e) {
@@ -1016,6 +1014,15 @@ class ExtendedFileUtility extends \TYPO3\CMS\Core\Utility\File\BasicFileUtility
                $defaultFlashMessageQueue->enqueue($flashMessage);
        }
 
+       /**
+        * Gets Indexer
+        *
+        * @param \TYPO3\CMS\Core\Resource\ResourceStorage $storage
+        * @return \TYPO3\CMS\Core\Resource\Index\Indexer
+        */
+       protected function getIndexer(\TYPO3\CMS\Core\Resource\ResourceStorage $storage) {
+               return GeneralUtility::makeInstance('TYPO3\\CMS\\Core\\Resource\\Index\\Indexer', $storage);
+       }
 
        /**
         * Get database connection
@@ -1033,16 +1040,4 @@ class ExtendedFileUtility extends \TYPO3\CMS\Core\Utility\File\BasicFileUtility
                return $GLOBALS['BE_USER'];
        }
 
-       /**
-        * Internal function to retrieve the indexer service,
-        * if it does not exist, an instance will be created
-        *
-        * @return \TYPO3\CMS\Core\Resource\Service\IndexerService
-        */
-       protected function getIndexerService() {
-               if ($this->indexerService === NULL) {
-                       $this->indexerService = GeneralUtility::makeInstance('TYPO3\\CMS\\Core\\Resource\\Service\\IndexerService');
-               }
-               return $this->indexerService;
-       }
 }