[TASK] Use file_exists() instead of is_file() 72/26872/2
authorOliver Hader <oliver@typo3.org>
Thu, 16 Jan 2014 11:12:06 +0000 (12:12 +0100)
committerBenjamin Mack <benni@typo3.org>
Thu, 16 Jan 2014 12:12:00 +0000 (13:12 +0100)
is_file() checks whether a resource exists and whether it
is actually a file. There are several parts in the core,
where it is sufficient to check for the existence only,
which is faster.

Resolves: #55052
Releases: 6.2
Change-Id: I57b6d2f68dd3c1c45b603c3f194cc0c53c48e28c
Reviewed-on: https://review.typo3.org/26872
Reviewed-by: Wouter Wolters
Reviewed-by: Tom Ruether
Tested-by: Tom Ruether
Reviewed-by: Oliver Klee
Reviewed-by: Benjamin Mack
Tested-by: Benjamin Mack
typo3/sysext/core/Classes/Compatibility/LoadedExtensionArrayElement.php
typo3/sysext/core/Classes/TypoScript/Parser/TypoScriptParser.php
typo3/sysext/core/Classes/TypoScript/TemplateService.php

index 5ccd0c6..495f664 100644 (file)
@@ -129,7 +129,7 @@ class LoadedExtensionArrayElement implements \IteratorAggregate, \ArrayAccess, \
        protected function initializeExtensionFiles() {
                foreach ($this->extensionFilesToCheckFor as $fileName) {
                        $absolutePathToFile = $this->package->getPackagePath() . $fileName;
-                       if (@is_file($absolutePathToFile)) {
+                       if (@file_exists($absolutePathToFile)) {
                                $this->extensionInformation[$fileName] = $absolutePathToFile;
                        }
                }
index 96ee4eb..462e26d 100644 (file)
@@ -824,7 +824,7 @@ class TypoScriptParser {
                        // Check for allowed files
                        if (!GeneralUtility::verifyFilenameAgainstDenyPattern($absfilename)) {
                                $newString .= self::typoscriptIncludeError('File "' . $filename . '" was not included since it is not allowed due to fileDenyPattern.');
-                       } elseif (!@is_file($absfilename)) {
+                       } elseif (!@file_exists($absfilename)) {
                                $newString .= self::typoscriptIncludeError('File "' . $filename . '" was not was not found.');
                        } else {
                                $includedFiles[] = $absfilename;
index 3e7a292..f9820bb 100644 (file)
@@ -788,10 +788,10 @@ class TemplateService {
                                                if (@is_dir($ISF_filePath)) {
                                                        $mExtKey = str_replace('_', '', $ISF_extKey . '/' . $ISF_localPath);
                                                        $subrow = array(
-                                                               'constants' => @is_file(($ISF_filePath . 'constants.txt')) ? GeneralUtility::getUrl($ISF_filePath . 'constants.txt') : '',
-                                                               'config' => @is_file(($ISF_filePath . 'setup.txt')) ? GeneralUtility::getUrl($ISF_filePath . 'setup.txt') : '',
-                                                               'include_static' => @is_file(($ISF_filePath . 'include_static.txt')) ? implode(',', array_unique(GeneralUtility::intExplode(',', GeneralUtility::getUrl($ISF_filePath . 'include_static.txt')))) : '',
-                                                               'include_static_file' => @is_file(($ISF_filePath . 'include_static_file.txt')) ? implode(',', array_unique(explode(',', GeneralUtility::getUrl($ISF_filePath . 'include_static_file.txt')))) : '',
+                                                               'constants' => @file_exists(($ISF_filePath . 'constants.txt')) ? GeneralUtility::getUrl($ISF_filePath . 'constants.txt') : '',
+                                                               'config' => @file_exists(($ISF_filePath . 'setup.txt')) ? GeneralUtility::getUrl($ISF_filePath . 'setup.txt') : '',
+                                                               'include_static' => @file_exists(($ISF_filePath . 'include_static.txt')) ? implode(',', array_unique(GeneralUtility::intExplode(',', GeneralUtility::getUrl($ISF_filePath . 'include_static.txt')))) : '',
+                                                               'include_static_file' => @file_exists(($ISF_filePath . 'include_static_file.txt')) ? implode(',', array_unique(explode(',', GeneralUtility::getUrl($ISF_filePath . 'include_static_file.txt')))) : '',
                                                                'title' => $ISF_file,
                                                                'uid' => $mExtKey
                                                        );
@@ -1247,7 +1247,7 @@ class TemplateService {
                                $extPath = \TYPO3\CMS\Core\Utility\ExtensionManagementUtility::extPath($extKey);
                                $newFile = \TYPO3\CMS\Core\Utility\PathUtility::stripPathSitePrefix($extPath) . $script;
                        }
-                       if (!@is_file((PATH_site . $newFile))) {
+                       if (!@file_exists((PATH_site . $newFile))) {
                                if ($this->tt_track) {
                                        $GLOBALS['TT']->setTSlogMessage('Extension media file "' . $newFile . '" was not found!', 3);
                                }
@@ -1263,10 +1263,10 @@ class TemplateService {
                if (strpos($file, '/') !== FALSE) {
                        // If the file is in the media/ folder but it doesn't exist,
                        // it is assumed that it's in the tslib folder
-                       if (GeneralUtility::isFirstPartOfStr($file, 'media/') && !is_file(($this->getFileName_backPath . $file))) {
+                       if (GeneralUtility::isFirstPartOfStr($file, 'media/') && !file_exists(($this->getFileName_backPath . $file))) {
                                $file = \TYPO3\CMS\Core\Utility\ExtensionManagementUtility::siteRelPath('cms') . 'tslib/' . $file;
                        }
-                       if (is_file($this->getFileName_backPath . $file)) {
+                       if (file_exists($this->getFileName_backPath . $file)) {
                                $outFile = $file;
                                $fileInfo = GeneralUtility::split_fileref($outFile);
                                $OK = 0;