diff --git a/typo3/sysext/core/Classes/Resource/File.php b/typo3/sysext/core/Classes/Resource/File.php index 8fbac8bef69a6975e716f50cc871b3541e061f65..d3832aca71fe48246dbc88cc0b1bc44465db3dc4 100644 --- a/typo3/sysext/core/Classes/Resource/File.php +++ b/typo3/sysext/core/Classes/Resource/File.php @@ -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; } diff --git a/typo3/sysext/core/Classes/Resource/ResourceFactory.php b/typo3/sysext/core/Classes/Resource/ResourceFactory.php index 549a57ffa3f74701f6bbc4a36b5f54f9bc4e3b20..986c6d3bee673a0f6b2af7ff01818cfa736c95f2 100644 --- a/typo3/sysext/core/Classes/Resource/ResourceFactory.php +++ b/typo3/sysext/core/Classes/Resource/ResourceFactory.php @@ -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); + } + } diff --git a/typo3/sysext/core/Classes/Resource/Service/IndexerService.php b/typo3/sysext/core/Classes/Resource/Service/IndexerService.php index 402fc5caeb81f5aa38d6d515959f4afee5b85e95..604edafbd63784b0feb6c073a58cb8cc60ed9e75 100644 --- a/typo3/sysext/core/Classes/Resource/Service/IndexerService.php +++ b/typo3/sysext/core/Classes/Resource/Service/IndexerService.php @@ -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 { diff --git a/typo3/sysext/core/Classes/Utility/File/ExtendedFileUtility.php b/typo3/sysext/core/Classes/Utility/File/ExtendedFileUtility.php index 6d2c437f129be19c41422de4f1744b27de46b4d0..e1905b084889e9db56f8ece50ebc548249bedea5 100644 --- a/typo3/sysext/core/Classes/Utility/File/ExtendedFileUtility.php +++ b/typo3/sysext/core/Classes/Utility/File/ExtendedFileUtility.php @@ -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; - } }