[TASK] Replace PATH_site with Environment API in EXT:frontend 33/57233/2
authorBenni Mack <benni@typo3.org>
Fri, 15 Jun 2018 14:42:13 +0000 (16:42 +0200)
committerJan Helke <typo3@helke.de>
Fri, 15 Jun 2018 15:26:05 +0000 (17:26 +0200)
Resolves: #85276
Releases: master
Change-Id: Id85d7538000ce05addaa5c3d4e3607e2ff20d42e
Reviewed-on: https://review.typo3.org/57233
Tested-by: TYPO3com <no-reply@typo3.com>
Reviewed-by: Christian Kuhn <lolli@schwarzbu.ch>
Tested-by: Christian Kuhn <lolli@schwarzbu.ch>
Reviewed-by: Jan Helke <typo3@helke.de>
Tested-by: Jan Helke <typo3@helke.de>
typo3/sysext/frontend/Classes/ContentObject/ContentObjectRenderer.php
typo3/sysext/frontend/Classes/ContentObject/Menu/GraphicalMenuContentObject.php
typo3/sysext/frontend/Classes/ContentObject/Menu/ImageMenuContentObject.php
typo3/sysext/frontend/Classes/Controller/TypoScriptFrontendController.php
typo3/sysext/frontend/Classes/Imaging/GifBuilder.php
typo3/sysext/frontend/Classes/Page/PageGenerator.php
typo3/sysext/frontend/Tests/Unit/ContentObject/ContentObjectRendererTest.php
typo3/sysext/frontend/Tests/Unit/ContentObject/FluidTemplateContentObjectTest.php

index c6d54d9..84cf5b2 100644 (file)
@@ -19,6 +19,7 @@ use Doctrine\DBAL\Driver\Statement;
 use Psr\Log\LoggerAwareInterface;
 use Psr\Log\LoggerAwareTrait;
 use TYPO3\CMS\Core\Cache\CacheManager;
+use TYPO3\CMS\Core\Core\Environment;
 use TYPO3\CMS\Core\Database\Connection;
 use TYPO3\CMS\Core\Database\ConnectionPool;
 use TYPO3\CMS\Core\Database\Query\QueryBuilder;
@@ -1038,7 +1039,7 @@ class ContentObjectRenderer implements LoggerAwareInterface
         if (!is_array($info)) {
             return '';
         }
-        if (is_file(PATH_site . $info['3'])) {
+        if (is_file(Environment::getPublicPath() . '/' . $info['3'])) {
             $source = $tsfe->absRefPrefix . str_replace('%2F', '/', rawurlencode($info['3']));
         } else {
             $source = $info[3];
index d2584a6..1e3017a 100644 (file)
@@ -14,6 +14,7 @@ namespace TYPO3\CMS\Frontend\ContentObject\Menu;
  * The TYPO3 project - inspiring people to share!
  */
 
+use TYPO3\CMS\Core\Core\Environment;
 use TYPO3\CMS\Core\Type\File\ImageInfo;
 use TYPO3\CMS\Core\TypoScript\TypoScriptService;
 use TYPO3\CMS\Core\Utility\GeneralUtility;
@@ -236,7 +237,7 @@ class GraphicalMenuContentObject extends AbstractMenuContentObject
             }
             // If an alternative name was NOT given, find the GIFBUILDER name.
             if (!$gifFileName && $isGD) {
-                GeneralUtility::mkdir_deep(PATH_site . 'typo3temp/assets/menu/');
+                GeneralUtility::mkdir_deep(Environment::getPublicPath() . '/typo3temp/assets/menu/');
                 $gifFileName = $gifCreator->fileName('assets/menu/');
             }
             $this->result[$resKey][$key] = $conf[$key];
index dab14ef..3d7dc4c 100644 (file)
@@ -14,6 +14,7 @@ namespace TYPO3\CMS\Frontend\ContentObject\Menu;
  * The TYPO3 project - inspiring people to share!
  */
 
+use TYPO3\CMS\Core\Core\Environment;
 use TYPO3\CMS\Core\Type\File\ImageInfo;
 use TYPO3\CMS\Core\Utility\ArrayUtility;
 use TYPO3\CMS\Core\Utility\GeneralUtility;
@@ -192,7 +193,7 @@ class ImageMenuContentObject extends AbstractMenuContentObject
                     echo '<h3>Renumbered GIFBUILDER object:</h3>';
                     debug($gifCreator->setup);
                 }
-                GeneralUtility::mkdir_deep(PATH_site . 'typo3temp/assets/menu/');
+                GeneralUtility::mkdir_deep(Environment::getPublicPath() . '/typo3temp/assets/menu/');
                 $gifFileName = $gifCreator->fileName('assets/menu/');
                 // Gets the ImageMap from the cache...
                 $cache = $this->getCache();
index 2daf787..f6a99bf 100644 (file)
@@ -25,6 +25,7 @@ use TYPO3\CMS\Core\Cache\CacheManager;
 use TYPO3\CMS\Core\Charset\CharsetConverter;
 use TYPO3\CMS\Core\Charset\UnknownCharsetException;
 use TYPO3\CMS\Core\Controller\ErrorPageController;
+use TYPO3\CMS\Core\Core\Environment;
 use TYPO3\CMS\Core\Database\ConnectionPool;
 use TYPO3\CMS\Core\Database\Query\QueryHelper;
 use TYPO3\CMS\Core\Database\Query\Restriction\DefaultRestrictionContainer;
@@ -4121,12 +4122,12 @@ class TypoScriptFrontendController implements LoggerAwareInterface
         } else {
             $trace = debug_backtrace(DEBUG_BACKTRACE_IGNORE_ARGS, 1);
             // This is a hack to work around ___FILE___ resolving symbolic links
-            $PATH_site_real = PathUtility::dirname(realpath(PATH_site . 'typo3')) . '/';
+            $PATH_site_real = PathUtility::dirname(realpath(Environment::getPublicPath() . '/typo3')) . '/';
             $file = $trace[0]['file'];
             if (strpos($file, $PATH_site_real) === 0) {
                 $file = str_replace($PATH_site_real, '', $file);
             } else {
-                $file = str_replace(PATH_site, '', $file);
+                $file = str_replace(Environment::getPublicPath() . '/', '', $file);
             }
             $line = $trace[0]['line'];
             $trigger = $file . ' on line ' . $line;
index 85fdf7c..4400f3a 100644 (file)
@@ -14,6 +14,7 @@ namespace TYPO3\CMS\Frontend\Imaging;
  * The TYPO3 project - inspiring people to share!
  */
 
+use TYPO3\CMS\Core\Core\Environment;
 use TYPO3\CMS\Core\Imaging\GraphicalFunctions;
 use TYPO3\CMS\Core\Resource\File;
 use TYPO3\CMS\Core\Resource\ProcessedFile;
@@ -340,12 +341,12 @@ class GifBuilder extends GraphicalFunctions
     public function gifBuild()
     {
         if ($this->setup) {
-            // Relative to PATH_site
+            // Relative to Environment::getPublicPath()
             $gifFileName = $this->fileName('assets/images/');
             // File exists
             if (!file_exists($gifFileName)) {
                 // Create temporary directory if not done:
-                GeneralUtility::mkdir_deep(PATH_site . 'typo3temp/assets/images/');
+                GeneralUtility::mkdir_deep(Environment::getPublicPath() . '/typo3temp/assets/images/');
                 // Create file:
                 $this->make();
                 $this->output($gifFileName);
@@ -690,7 +691,7 @@ class GifBuilder extends GraphicalFunctions
      * something like "GB_MD5HASH_myfilename_is_very_long_and_such.jpg"
      *
      * @param string $pre Filename prefix, eg. "GB_
-     * @return string The relative filepath (relative to PATH_site)
+     * @return string The filepath, relative to Environment::getPublicPath()
      * @access private
      */
     public function fileName($pre)
index 4ce8b6c..a6936da 100644 (file)
@@ -15,6 +15,7 @@ namespace TYPO3\CMS\Frontend\Page;
  */
 
 use Psr\Http\Message\ServerRequestInterface;
+use TYPO3\CMS\Core\Core\Environment;
 use TYPO3\CMS\Core\Page\PageRenderer;
 use TYPO3\CMS\Core\Site\Entity\SiteLanguage;
 use TYPO3\CMS\Core\TimeTracker\TimeTracker;
@@ -242,7 +243,7 @@ class PageGenerator
         }
         if ($tsfe->pSetup['shortcutIcon']) {
             $favIcon = ltrim($tsfe->tmpl->getFileName($tsfe->pSetup['shortcutIcon']), '/');
-            $iconFileInfo = GeneralUtility::makeInstance(ImageInfo::class, PATH_site . $favIcon);
+            $iconFileInfo = GeneralUtility::makeInstance(ImageInfo::class, Environment::getPublicPath() . '/' . $favIcon);
             if ($iconFileInfo->isFile()) {
                 $iconMimeType = $iconFileInfo->getMimeType();
                 if ($iconMimeType) {
@@ -804,8 +805,8 @@ class PageGenerator
                 break;
         }
         // Write file
-        if ($script && !@is_file(PATH_site . $script)) {
-            GeneralUtility::writeFileToTypo3tempDir(PATH_site . $script, $str);
+        if ($script && !@is_file(Environment::getPublicPath() . '/' . $script)) {
+            GeneralUtility::writeFileToTypo3tempDir(Environment::getPublicPath() . '/' . $script, $str);
         }
         return $script;
     }
index 46f100d..74c8ef1 100644 (file)
@@ -18,6 +18,7 @@ use Prophecy\Argument;
 use TYPO3\CMS\Core\Cache\CacheManager;
 use TYPO3\CMS\Core\Cache\Frontend\FrontendInterface as CacheFrontendInterface;
 use TYPO3\CMS\Core\Core\ApplicationContext;
+use TYPO3\CMS\Core\Core\Environment;
 use TYPO3\CMS\Core\LinkHandling\LinkService;
 use TYPO3\CMS\Core\Log\Logger;
 use TYPO3\CMS\Core\Resource\Exception\InvalidPathException;
@@ -3117,10 +3118,10 @@ class ContentObjectRendererTest extends UnitTestCase
      */
     public function filelinkCreatesCorrectUrlForFileWithUrlEncodedSpecialChars()
     {
-        $fileNameAndPath = PATH_site . 'typo3temp/var/tests/phpunitJumpUrlTestFile with spaces & amps.txt';
+        $fileNameAndPath = Environment::getPublicPath() . '/typo3temp/var/tests/phpunitJumpUrlTestFile with spaces & amps.txt';
         file_put_contents($fileNameAndPath, 'Some test data');
-        $relativeFileNameAndPath = substr($fileNameAndPath, strlen(PATH_site));
-        $fileName = substr($fileNameAndPath, strlen(PATH_site . 'typo3temp/var/tests/'));
+        $relativeFileNameAndPath = substr($fileNameAndPath, strlen(Environment::getPublicPath()) + 1);
+        $fileName = substr($fileNameAndPath, strlen(Environment::getPublicPath() . '/typo3temp/var/tests/'));
 
         $expectedLink = str_replace('%2F', '/', rawurlencode($relativeFileNameAndPath));
         $result = $this->subject->filelink($fileName, ['path' => 'typo3temp/var/tests/']);
index b630cfc..b6587e3 100644 (file)
@@ -14,6 +14,7 @@ namespace TYPO3\CMS\Frontend\Tests\Unit\ContentObject;
  * The TYPO3 project - inspiring people to share!
  */
 
+use TYPO3\CMS\Core\Core\Environment;
 use TYPO3\CMS\Core\Page\PageRenderer;
 use TYPO3\CMS\Core\TypoScript\TypoScriptService;
 use TYPO3\CMS\Core\Utility\GeneralUtility;
@@ -179,7 +180,7 @@ class FluidTemplateContentObjectTest extends \TYPO3\TestingFramework\Core\Unit\U
         $this->standaloneView
             ->expects($this->any())
             ->method('setTemplatePathAndFilename')
-            ->with(PATH_site . 'typo3/sysext/core/bar.html');
+            ->with(Environment::getPublicPath() . '/typo3/sysext/core/bar.html');
         $this->subject->render(['file' => 'EXT:core/bar.html']);
     }
 
@@ -193,7 +194,7 @@ class FluidTemplateContentObjectTest extends \TYPO3\TestingFramework\Core\Unit\U
         $this->contentObjectRenderer
             ->expects($this->any())
             ->method('cObjGetSingle')
-            ->with('FILE', ['file' => PATH_site . 'foo/bar.html'])
+            ->with('FILE', ['file' => Environment::getPublicPath() . '/foo/bar.html'])
             ->will($this->returnValue('baz'));
 
         $this->standaloneView
@@ -204,7 +205,7 @@ class FluidTemplateContentObjectTest extends \TYPO3\TestingFramework\Core\Unit\U
         $this->subject->render([
             'template' => 'FILE',
             'template.' => [
-                'file' => PATH_site . 'foo/bar.html'
+                'file' => Environment::getPublicPath() . '/foo/bar.html'
             ]
         ]);
     }
@@ -276,7 +277,7 @@ class FluidTemplateContentObjectTest extends \TYPO3\TestingFramework\Core\Unit\U
         $this->standaloneView
             ->expects($this->once())
             ->method('setLayoutRootPaths')
-            ->with([PATH_site . 'foo/bar.html']);
+            ->with([Environment::getPublicPath() . '/foo/bar.html']);
         $this->subject->render(['layoutRootPath' => 'foo/bar.html']);
     }
 
@@ -325,7 +326,7 @@ class FluidTemplateContentObjectTest extends \TYPO3\TestingFramework\Core\Unit\U
         $this->standaloneView
             ->expects($this->once())
             ->method('setLayoutRootPaths')
-            ->with([10 => PATH_site . 'foo/bar.html', 20 => PATH_site . 'foo/bar2.html']);
+            ->with([10 => Environment::getPublicPath() . '/foo/bar.html', 20 => Environment::getPublicPath() . '/foo/bar2.html']);
         $this->subject->render(['layoutRootPaths.' => [10 => 'foo/bar.html', 20 => 'foo/bar2.html']]);
     }
 
@@ -338,7 +339,7 @@ class FluidTemplateContentObjectTest extends \TYPO3\TestingFramework\Core\Unit\U
         $this->standaloneView
             ->expects($this->once())
             ->method('setLayoutRootPaths')
-            ->with([0 => PATH_site . 'foo/main.html', 10 => PATH_site . 'foo/bar.html', 20 => PATH_site . 'foo/bar2.html']);
+            ->with([0 => Environment::getPublicPath() . '/foo/main.html', 10 => Environment::getPublicPath() . '/foo/bar.html', 20 => Environment::getPublicPath() . '/foo/bar2.html']);
         $this->subject->render(['layoutRootPath' => 'foo/main.html', 'layoutRootPaths.' => [10 => 'foo/bar.html', 20 => 'foo/bar2.html']]);
     }
 
@@ -351,7 +352,7 @@ class FluidTemplateContentObjectTest extends \TYPO3\TestingFramework\Core\Unit\U
         $this->standaloneView
             ->expects($this->once())
             ->method('setPartialRootPaths')
-            ->with([PATH_site . 'foo/bar.html']);
+            ->with([Environment::getPublicPath() . '/foo/bar.html']);
         $this->subject->render(['partialRootPath' => 'foo/bar.html']);
     }
 
@@ -400,7 +401,7 @@ class FluidTemplateContentObjectTest extends \TYPO3\TestingFramework\Core\Unit\U
         $this->standaloneView
             ->expects($this->once())
             ->method('setPartialRootPaths')
-            ->with([10 => PATH_site . 'foo', 20 => PATH_site . 'bar']);
+            ->with([10 => Environment::getPublicPath() . '/foo', 20 => Environment::getPublicPath() . '/bar']);
         $this->subject->render(['partialRootPaths.' => [10 => 'foo', 20 => 'bar']]);
     }
 
@@ -413,7 +414,7 @@ class FluidTemplateContentObjectTest extends \TYPO3\TestingFramework\Core\Unit\U
         $this->standaloneView
             ->expects($this->once())
             ->method('setPartialRootPaths')
-            ->with([0 => PATH_site . 'main', 10 => PATH_site . 'foo', 20 => PATH_site . 'bar']);
+            ->with([0 => Environment::getPublicPath() . '/main', 10 => Environment::getPublicPath() . '/foo', 20 => Environment::getPublicPath() . '/bar']);
         $this->subject->render(['partialRootPath' => 'main', 'partialRootPaths.' => [10 => 'foo', 20 => 'bar']]);
     }