[BUGFIX] Avoid to get a file object with the uid zero 04/27304/3
authorMarc Bastian Heinrichs <typo3@mbh-software.de>
Mon, 3 Feb 2014 17:34:58 +0000 (18:34 +0100)
committerMarkus Klein <klein.t3@mfc-linz.at>
Wed, 26 Feb 2014 20:58:49 +0000 (21:58 +0100)
At some points where a file object is retrieved, a check for
the interpretation as integer is done for the method
argument only. If the argument is 0 a exception will be
thrown from the ResourceFactory.
A file object should only be fetched if the uid is an integer
greater than zero.

Resolves: #55530
Releases: 6.2
Change-Id: I9399d58bac4a48344769ac00207b64e25eea630e
Reviewed-on: https://review.typo3.org/27304
Reviewed-by: Wouter Wolters
Tested-by: Wouter Wolters
Reviewed-by: Markus Klein
Tested-by: Markus Klein
typo3/sysext/backend/Classes/View/ThumbnailView.php
typo3/sysext/core/Classes/DataHandling/DataHandler.php
typo3/sysext/frontend/Classes/ContentObject/MediaContentObject.php

index 2281ccb..c297fa2 100644 (file)
@@ -119,7 +119,7 @@ class ThumbnailView {
                // We need to distinguish it from absolute Windows paths by cbecking for an integer as first part.
                $parts = GeneralUtility::trimExplode(':', $filePathOrCombinedFileIdentifier);
                // Best case: we get a sys_file UID
-               if (MathUtility::canBeInterpretedAsInteger($filePathOrCombinedFileIdentifier)) {
+               if (!empty($filePathOrCombinedFileIdentifier) && MathUtility::canBeInterpretedAsInteger($filePathOrCombinedFileIdentifier)) {
                        /** @var File $filePathOrCombinedFileIdentifier */
                        $fileObject = ResourceFactory::getInstance()->getFileObject($filePathOrCombinedFileIdentifier);
                } elseif (count($parts) <= 1 || !MathUtility::canBeInterpretedAsInteger($parts[0])) {
index 63d91eb..8de75cf 100644 (file)
@@ -1984,7 +1984,7 @@ class DataHandler {
                                        $theDestFile = '';
                                        // a FAL file was added, now resolve the file object and get the absolute path
                                        // @todo in future versions this needs to be modified to handle FAL objects natively
-                                       if (\TYPO3\CMS\Core\Utility\MathUtility::canBeInterpretedAsInteger($theFile)) {
+                                       if (!empty($theFile) && \TYPO3\CMS\Core\Utility\MathUtility::canBeInterpretedAsInteger($theFile)) {
                                                $fileObject = \TYPO3\CMS\Core\Resource\ResourceFactory::getInstance()->getFileObject($theFile);
                                                $theFile = $fileObject->getForLocalProcessing(FALSE);
                                        }
@@ -2085,7 +2085,7 @@ class DataHandler {
                                        $propArr = $this->getRecordProperties($table, $id);
                                        foreach ($valueArray as &$theFile) {
                                                // FAL handling: it's a UID, thus it is resolved to the absolute path
-                                               if (\TYPO3\CMS\Core\Utility\MathUtility::canBeInterpretedAsInteger($theFile)) {
+                                               if (!empty($theFile) && \TYPO3\CMS\Core\Utility\MathUtility::canBeInterpretedAsInteger($theFile)) {
                                                        $fileObject = \TYPO3\CMS\Core\Resource\ResourceFactory::getInstance()->getFileObject($theFile);
                                                        $theFile = $fileObject->getForLocalProcessing(FALSE);
                                                }
index 409bf05..699e130 100644 (file)
@@ -259,10 +259,10 @@ class MediaContentObject extends \TYPO3\CMS\Frontend\ContentObject\AbstractConte
                /** @var $mediaWizard \TYPO3\CMS\Frontend\MediaWizard\MediaWizardProviderInterface */
                $mediaWizard = \TYPO3\CMS\Frontend\MediaWizard\MediaWizardProviderManager::getValidMediaWizardProvider($fileParts[0]);
                // Get the path relative to the page currently outputted
-               if (substr($fileParts[0], 0, 5) === "file:") {
+               if (substr($fileParts[0], 0, 5) === 'file:') {
                        $fileUid = substr($fileParts[0], 5);
 
-                       if (\TYPO3\CMS\Core\Utility\MathUtility::canBeInterpretedAsInteger($fileUid)) {
+                       if (!empty($fileUid) && \TYPO3\CMS\Core\Utility\MathUtility::canBeInterpretedAsInteger($fileUid)) {
                                $fileObject = \TYPO3\CMS\Core\Resource\ResourceFactory::getInstance()->getFileObject($fileUid);
 
                                if ($fileObject instanceof \TYPO3\CMS\Core\Resource\FileInterface) {