[TASK] Use general functionality for fetching templates 53/54753/3
authorBenni Mack <benni@typo3.org>
Fri, 24 Nov 2017 22:27:52 +0000 (23:27 +0100)
committerSusanne Moog <susanne.moog@typo3.org>
Mon, 27 Nov 2017 17:00:35 +0000 (18:00 +0100)
Some places in the TYPO3 Core can use the general coding functionality
to fetch absolute URLs, but "GeneralUtility::getFileAbsFileName" should
be used in these places.

Resolves: #83084
Releases: master
Change-Id: Ic723060b4b01eac51256d54e619a7770e0ad65fa
Reviewed-on: https://review.typo3.org/54753
Tested-by: TYPO3com <no-reply@typo3.com>
Reviewed-by: Georg Ringer <georg.ringer@gmail.com>
Tested-by: Georg Ringer <georg.ringer@gmail.com>
Reviewed-by: Susanne Moog <susanne.moog@typo3.org>
Tested-by: Susanne Moog <susanne.moog@typo3.org>
typo3/sysext/backend/Classes/Template/DocumentTemplate.php
typo3/sysext/frontend/Classes/ContentObject/FluidTemplateContentObject.php
typo3/sysext/frontend/Tests/Unit/ContentObject/FluidTemplateContentObjectTest.php

index dd9e90a..9d05214 100644 (file)
@@ -741,18 +741,8 @@ function jumpToUrl(URL) {
         if ($GLOBALS['TBE_STYLES']['htmlTemplates'][$filename]) {
             $filename = $GLOBALS['TBE_STYLES']['htmlTemplates'][$filename];
         }
-        if (GeneralUtility::isFirstPartOfStr($filename, 'EXT:')) {
-            $filename = GeneralUtility::getFileAbsFileName($filename);
-        } elseif (!GeneralUtility::isAbsPath($filename)) {
-            $filename = GeneralUtility::resolveBackPath($filename);
-        } elseif (!GeneralUtility::isAllowedAbsPath($filename)) {
-            $filename = '';
-        }
-        $htmlTemplate = '';
-        if ($filename !== '') {
-            $htmlTemplate = file_get_contents($filename);
-        }
-        return $htmlTemplate;
+        $filename = GeneralUtility::getFileAbsFileName($filename);
+        return $filename !== '' ? file_get_contents($filename) : '';
     }
 
     /**
index dbc3d29..85cae47 100644 (file)
@@ -173,10 +173,9 @@ class FluidTemplateContentObject extends AbstractContentObject
         } else {
             // Fetch the Fluid template by file stdWrap
             $file = isset($conf['file.']) ? $this->cObj->stdWrap($conf['file'], $conf['file.']) : $conf['file'];
-            /** @var $templateService \TYPO3\CMS\Core\TypoScript\TemplateService */
-            $templateService = $GLOBALS['TSFE']->tmpl;
-            $templatePathAndFilename = $templateService->getFileName($file);
-            $this->view->setTemplatePathAndFilename(PATH_site . $templatePathAndFilename);
+            // Get the absolute file name
+            $templatePathAndFilename = GeneralUtility::getFileAbsFileName($file);
+            $this->view->setTemplatePathAndFilename($templatePathAndFilename);
         }
     }
 
index 54fe0a8..b4e4ac7 100644 (file)
@@ -181,18 +181,11 @@ class FluidTemplateContentObjectTest extends \TYPO3\TestingFramework\Core\Unit\U
     public function renderSetsTemplateFileInView()
     {
         $this->addMockViewToSubject();
-        /** @var $templateService \PHPUnit_Framework_MockObject_MockObject */
-        $templateService = $GLOBALS['TSFE']->tmpl;
-        $templateService
-            ->expects($this->any())
-            ->method('getFileName')
-            ->with('foo')
-            ->will($this->returnValue('bar'));
         $this->standaloneView
             ->expects($this->any())
             ->method('setTemplatePathAndFilename')
-            ->with(PATH_site . 'bar');
-        $this->subject->render(['file' => 'foo']);
+            ->with(PATH_site . 'typo3/sysext/core/bar.html');
+        $this->subject->render(['file' => 'EXT:core/bar.html']);
     }
 
     /**