From f22fa503f1a316456a4aedea1c83a615d5b4300d Mon Sep 17 00:00:00 2001
From: Christian Kuhn <lolli@schwarzbu.ch>
Date: Fri, 15 Jun 2018 17:40:44 +0200
Subject: [PATCH] [TASK] Use Environment API instead of PATH_site in install

Resolves: #85280
Releases: master
Change-Id: Id8330e1fda17557284ab5ffd6081433226c74083
Reviewed-on: https://review.typo3.org/57237
Tested-by: TYPO3com <no-reply@typo3.com>
Reviewed-by: Jan Helke <typo3@helke.de>
Tested-by: Jan Helke <typo3@helke.de>
Reviewed-by: Benni Mack <benni@typo3.org>
Tested-by: Benni Mack <benni@typo3.org>
---
 .../Controller/EnvironmentController.php      | 57 ++++++++++---------
 .../Classes/Controller/UpgradeController.php  |  8 +--
 .../Classes/FolderStructure/AbstractNode.php  | 10 ++--
 .../FolderStructure/DefaultFactory.php        | 16 +++---
 .../Classes/Report/SecurityStatusReport.php   |  3 +-
 .../Classes/Service/CoreUpdateService.php     | 10 ++--
 .../Classes/Service/EnableFileService.php     | 16 ++----
 .../Classes/Service/Typo3tempFileService.php  |  5 +-
 .../Updates/BackendLayoutIconUpdateWizard.php |  5 +-
 .../Updates/FrontendUserImageUpdateWizard.php |  9 +--
 .../Environment/FolderStructure.html          |  3 +-
 .../Unit/FolderStructure/AbstractNodeTest.php | 11 ++--
 .../FolderStructure/DirectoryNodeTest.php     |  3 +-
 .../Unit/FolderStructure/FileNodeTest.php     |  5 +-
 .../Unit/FolderStructure/LinkNodeTest.php     | 21 +++----
 .../Unit/FolderStructure/RootNodeTest.php     |  5 +-
 .../Unit/Service/EnableFileServiceTest.php    | 46 ++++++++++++---
 17 files changed, 131 insertions(+), 102 deletions(-)

diff --git a/typo3/sysext/install/Classes/Controller/EnvironmentController.php b/typo3/sysext/install/Classes/Controller/EnvironmentController.php
index 887b8655ba6e..12f6642d472c 100644
--- a/typo3/sysext/install/Classes/Controller/EnvironmentController.php
+++ b/typo3/sysext/install/Classes/Controller/EnvironmentController.php
@@ -171,6 +171,8 @@ class EnvironmentController extends AbstractController
 
         $permissionCheck = GeneralUtility::makeInstance(DefaultPermissionsCheck::class);
 
+        $view->assign('publicPath', Environment::getPublicPath());
+
         return new JsonResponse([
             'success' => true,
             'errorStatus' => $errorQueue,
@@ -297,7 +299,7 @@ class EnvironmentController extends AbstractController
             ExtensionManagementUtility::extPath('install') . 'Resources/Private/Font/vera.ttf',
             'Testing true type'
         );
-        $outputFile = PATH_site . 'typo3temp/assets/images/installTool-' . StringUtility::getUniqueId('createTrueTypeFontTestImage') . '.gif';
+        $outputFile = Environment::getPublicPath() . '/typo3temp/assets/images/installTool-' . StringUtility::getUniqueId('createTrueTypeFontTestImage') . '.gif';
         imagegif($image, $outputFile);
         $fileExists = file_exists($outputFile);
         if ($fileExists) {
@@ -306,7 +308,7 @@ class EnvironmentController extends AbstractController
         return $this->getImageTestResponse([
             'fileExists' => $fileExists,
             'outputFile' => $outputFile,
-            'referenceFile' => PATH_site . 'typo3/sysext/install/Resources/Public/Images/TestReference/Font.gif',
+            'referenceFile' => Environment::getPublicPath() . '/typo3/sysext/install/Resources/Public/Images/TestReference/Font.gif',
         ]);
     }
 
@@ -412,7 +414,7 @@ class EnvironmentController extends AbstractController
                 'status' => $messages,
                 'fileExists' => true,
                 'outputFile' => $imResult[3],
-                'referenceFile' => PATH_site . 'typo3/sysext/install/Resources/Public/Images/TestReference/Write-gif.gif',
+                'referenceFile' => Environment::getPublicPath() . '/typo3/sysext/install/Resources/Public/Images/TestReference/Write-gif.gif',
                 'command' => $imageProcessor->IM_commands,
             ];
         } else {
@@ -445,7 +447,7 @@ class EnvironmentController extends AbstractController
             $result = [
                 'fileExists' => true,
                 'outputFile' => $imResult[3],
-                'referenceFile' => PATH_site . 'typo3/sysext/install/Resources/Public/Images/TestReference/Write-png.png',
+                'referenceFile' => Environment::getPublicPath() . '/typo3/sysext/install/Resources/Public/Images/TestReference/Write-png.png',
                 'command' => $imageProcessor->IM_commands,
             ];
         } else {
@@ -478,7 +480,7 @@ class EnvironmentController extends AbstractController
             $result = [
                 'fileExists' => true,
                 'outputFile' => $imResult[3],
-                'referenceFile' => PATH_site . 'typo3/sysext/install/Resources/Public/Images/TestReference/Scale-gif.gif',
+                'referenceFile' => Environment::getPublicPath() . '/typo3/sysext/install/Resources/Public/Images/TestReference/Scale-gif.gif',
                 'command' => $imageProcessor->IM_commands,
             ];
         } else {
@@ -511,7 +513,7 @@ class EnvironmentController extends AbstractController
             $result = [
                 'fileExists' => true,
                 'outputFile' => $imResult[3],
-                'referenceFile' => PATH_site . 'typo3/sysext/install/Resources/Public/Images/TestReference/Scale-png.png',
+                'referenceFile' => Environment::getPublicPath() . '/typo3/sysext/install/Resources/Public/Images/TestReference/Scale-png.png',
                 'command' => $imageProcessor->IM_commands,
             ];
         } else {
@@ -544,7 +546,7 @@ class EnvironmentController extends AbstractController
             $result = [
                 'fileExists' => true,
                 'outputFile' => $imResult[3],
-                'referenceFile' => PATH_site . 'typo3/sysext/install/Resources/Public/Images/TestReference/Scale-jpg.jpg',
+                'referenceFile' => Environment::getPublicPath() . '/typo3/sysext/install/Resources/Public/Images/TestReference/Scale-jpg.jpg',
                 'command' => $imageProcessor->IM_commands,
             ];
         } else {
@@ -573,7 +575,7 @@ class EnvironmentController extends AbstractController
         $inputFile = $imageBasePath . 'TestInput/BackgroundOrange.gif';
         $overlayFile = $imageBasePath . 'TestInput/Test.jpg';
         $maskFile = $imageBasePath . 'TestInput/MaskBlackWhite.gif';
-        $resultFile = $this->getImagesPath($imageProcessor) . $imageProcessor->filenamePrefix
+        $resultFile = $this->getImagesPath() . $imageProcessor->filenamePrefix
             . StringUtility::getUniqueId($imageProcessor->alternativeOutputKey . 'combine1') . '.jpg';
         $imageProcessor->combineExec($inputFile, $overlayFile, $maskFile, $resultFile);
         $imResult = $imageProcessor->getImageDimensions($resultFile);
@@ -581,7 +583,7 @@ class EnvironmentController extends AbstractController
             $result = [
                 'fileExists' => true,
                 'outputFile' => $imResult[3],
-                'referenceFile' => PATH_site . 'typo3/sysext/install/Resources/Public/Images/TestReference/Combine-1.jpg',
+                'referenceFile' => Environment::getPublicPath() . '/typo3/sysext/install/Resources/Public/Images/TestReference/Combine-1.jpg',
                 'command' => $imageProcessor->IM_commands,
             ];
         } else {
@@ -610,7 +612,7 @@ class EnvironmentController extends AbstractController
         $inputFile = $imageBasePath . 'TestInput/BackgroundCombine.jpg';
         $overlayFile = $imageBasePath . 'TestInput/Test.jpg';
         $maskFile = $imageBasePath . 'TestInput/MaskCombine.jpg';
-        $resultFile = $this->getImagesPath($imageProcessor) . $imageProcessor->filenamePrefix
+        $resultFile = $this->getImagesPath() . $imageProcessor->filenamePrefix
             . StringUtility::getUniqueId($imageProcessor->alternativeOutputKey . 'combine2') . '.jpg';
         $imageProcessor->combineExec($inputFile, $overlayFile, $maskFile, $resultFile);
         $imResult = $imageProcessor->getImageDimensions($resultFile);
@@ -618,7 +620,7 @@ class EnvironmentController extends AbstractController
             $result = [
                 'fileExists' => true,
                 'outputFile' => $imResult[3],
-                'referenceFile' => PATH_site . 'typo3/sysext/install/Resources/Public/Images/TestReference/Combine-2.jpg',
+                'referenceFile' => Environment::getPublicPath() . '/typo3/sysext/install/Resources/Public/Images/TestReference/Combine-2.jpg',
                 'command' => $imageProcessor->IM_commands,
             ];
         } else {
@@ -648,13 +650,13 @@ class EnvironmentController extends AbstractController
             'color' => 'olive',
         ];
         $imageProcessor->makeBox($image, $conf, $workArea);
-        $outputFile = $this->getImagesPath($imageProcessor) . $imageProcessor->filenamePrefix . StringUtility::getUniqueId('gdSimple') . '.' . $gifOrPng;
+        $outputFile = $this->getImagesPath() . $imageProcessor->filenamePrefix . StringUtility::getUniqueId('gdSimple') . '.' . $gifOrPng;
         $imageProcessor->ImageWrite($image, $outputFile);
         $imResult = $imageProcessor->getImageDimensions($outputFile);
         $result = [
             'fileExists' => true,
             'outputFile' => $imResult[3],
-            'referenceFile' => PATH_site . 'typo3/sysext/install/Resources/Public/Images/TestReference/Gdlib-simple.' . $gifOrPng,
+            'referenceFile' => Environment::getPublicPath() . '/typo3/sysext/install/Resources/Public/Images/TestReference/Gdlib-simple.' . $gifOrPng,
             'command' => $imageProcessor->IM_commands,
         ];
         return $this->getImageTestResponse($result);
@@ -678,13 +680,13 @@ class EnvironmentController extends AbstractController
             'color' => 'olive',
         ];
         $imageProcessor->makeBox($image, $conf, $workArea);
-        $outputFile = $this->getImagesPath($imageProcessor) . $imageProcessor->filenamePrefix . StringUtility::getUniqueId('gdBox') . '.' . $gifOrPng;
+        $outputFile = $this->getImagesPath() . $imageProcessor->filenamePrefix . StringUtility::getUniqueId('gdBox') . '.' . $gifOrPng;
         $imageProcessor->ImageWrite($image, $outputFile);
         $imResult = $imageProcessor->getImageDimensions($outputFile);
         $result = [
             'fileExists' => true,
             'outputFile' => $imResult[3],
-            'referenceFile' => PATH_site . 'typo3/sysext/install/Resources/Public/Images/TestReference/Gdlib-box.' . $gifOrPng,
+            'referenceFile' => Environment::getPublicPath() . '/typo3/sysext/install/Resources/Public/Images/TestReference/Gdlib-box.' . $gifOrPng,
             'command' => $imageProcessor->IM_commands,
         ];
         return $this->getImageTestResponse($result);
@@ -715,13 +717,13 @@ class EnvironmentController extends AbstractController
         ];
         $conf['BBOX'] = $imageProcessor->calcBBox($conf);
         $imageProcessor->makeText($image, $conf, $workArea);
-        $outputFile = $this->getImagesPath($imageProcessor) . $imageProcessor->filenamePrefix . StringUtility::getUniqueId('gdText') . '.' . $gifOrPng;
+        $outputFile = $this->getImagesPath() . $imageProcessor->filenamePrefix . StringUtility::getUniqueId('gdText') . '.' . $gifOrPng;
         $imageProcessor->ImageWrite($image, $outputFile);
         $imResult = $imageProcessor->getImageDimensions($outputFile);
         $result = [
             'fileExists' => true,
             'outputFile' => $imResult[3],
-            'referenceFile' => PATH_site . 'typo3/sysext/install/Resources/Public/Images/TestReference/Gdlib-text.' . $gifOrPng,
+            'referenceFile' => Environment::getPublicPath() . '/typo3/sysext/install/Resources/Public/Images/TestReference/Gdlib-text.' . $gifOrPng,
             'command' => $imageProcessor->IM_commands,
         ];
         return $this->getImageTestResponse($result);
@@ -757,18 +759,18 @@ class EnvironmentController extends AbstractController
         ];
         $conf['BBOX'] = $imageProcessor->calcBBox($conf);
         $imageProcessor->makeText($image, $conf, $workArea);
-        $outputFile = $this->getImagesPath($imageProcessor) . $imageProcessor->filenamePrefix . StringUtility::getUniqueId('gdText') . '.' . $gifOrPng;
+        $outputFile = $this->getImagesPath() . $imageProcessor->filenamePrefix . StringUtility::getUniqueId('gdText') . '.' . $gifOrPng;
         $imageProcessor->ImageWrite($image, $outputFile);
         $conf['offset'] = '30,120';
         $conf['niceText'] = 1;
         $imageProcessor->makeText($image, $conf, $workArea);
-        $outputFile = $this->getImagesPath($imageProcessor) . $imageProcessor->filenamePrefix . StringUtility::getUniqueId('gdNiceText') . '.' . $gifOrPng;
+        $outputFile = $this->getImagesPath() . $imageProcessor->filenamePrefix . StringUtility::getUniqueId('gdNiceText') . '.' . $gifOrPng;
         $imageProcessor->ImageWrite($image, $outputFile);
         $imResult = $imageProcessor->getImageDimensions($outputFile);
         $result = [
             'fileExists' => true,
             'outputFile' => $imResult[3],
-            'referenceFile' => PATH_site . 'typo3/sysext/install/Resources/Public/Images/TestReference/Gdlib-niceText.' . $gifOrPng,
+            'referenceFile' => Environment::getPublicPath() . '/typo3/sysext/install/Resources/Public/Images/TestReference/Gdlib-niceText.' . $gifOrPng,
             'command' => $imageProcessor->IM_commands,
         ];
         return $this->getImageTestResponse($result);
@@ -804,12 +806,12 @@ class EnvironmentController extends AbstractController
         ];
         $conf['BBOX'] = $imageProcessor->calcBBox($conf);
         $imageProcessor->makeText($image, $conf, $workArea);
-        $outputFile = $this->getImagesPath($imageProcessor) . $imageProcessor->filenamePrefix . StringUtility::getUniqueId('gdText') . '.' . $gifOrPng;
+        $outputFile = $this->getImagesPath() . $imageProcessor->filenamePrefix . StringUtility::getUniqueId('gdText') . '.' . $gifOrPng;
         $imageProcessor->ImageWrite($image, $outputFile);
         $conf['offset'] = '30,120';
         $conf['niceText'] = 1;
         $imageProcessor->makeText($image, $conf, $workArea);
-        $outputFile = $this->getImagesPath($imageProcessor) . $imageProcessor->filenamePrefix . StringUtility::getUniqueId('gdNiceText') . '.' . $gifOrPng;
+        $outputFile = $this->getImagesPath() . $imageProcessor->filenamePrefix . StringUtility::getUniqueId('gdNiceText') . '.' . $gifOrPng;
         $imageProcessor->ImageWrite($image, $outputFile);
         $conf['offset'] = '30,160';
         $conf['niceText'] = 1;
@@ -822,13 +824,13 @@ class EnvironmentController extends AbstractController
         // Warning: Re-uses $image from above!
         $imageProcessor->makeShadow($image, $conf['shadow.'], $workArea, $conf);
         $imageProcessor->makeText($image, $conf, $workArea);
-        $outputFile = $this->getImagesPath($imageProcessor) . $imageProcessor->filenamePrefix . StringUtility::getUniqueId('GDwithText-niceText-shadow') . '.' . $gifOrPng;
+        $outputFile = $this->getImagesPath() . $imageProcessor->filenamePrefix . StringUtility::getUniqueId('GDwithText-niceText-shadow') . '.' . $gifOrPng;
         $imageProcessor->ImageWrite($image, $outputFile);
         $imResult = $imageProcessor->getImageDimensions($outputFile);
         $result = [
             'fileExists' => true,
             'outputFile' => $imResult[3],
-            'referenceFile' => PATH_site . 'typo3/sysext/install/Resources/Public/Images/TestReference/Gdlib-shadow.' . $gifOrPng,
+            'referenceFile' => Environment::getPublicPath() . '/typo3/sysext/install/Resources/Public/Images/TestReference/Gdlib-shadow.' . $gifOrPng,
             'command' => $imageProcessor->IM_commands,
         ];
         return $this->getImageTestResponse($result);
@@ -903,7 +905,7 @@ class EnvironmentController extends AbstractController
             $result = [
                 'fileExists' => file_exists($imResult[3]),
                 'outputFile' => $imResult[3],
-                'referenceFile' => PATH_site . 'typo3/sysext/install/Resources/Public/Images/TestReference/Read-' . $inputFormat . '.jpg',
+                'referenceFile' => Environment::getPublicPath() . '/typo3/sysext/install/Resources/Public/Images/TestReference/Read-' . $inputFormat . '.jpg',
                 'command' => $imageProcessor->IM_commands,
             ];
         } else {
@@ -1066,12 +1068,11 @@ class EnvironmentController extends AbstractController
      * Return the temp image dir.
      * If not exist it will be created
      *
-     * @param GraphicalFunctions $imageProcessor
      * @return string
      */
-    protected function getImagesPath(GraphicalFunctions $imageProcessor): string
+    protected function getImagesPath(): string
     {
-        $imagePath = PATH_site . 'typo3temp/assets/images/';
+        $imagePath = Environment::getPublicPath() . '/typo3temp/assets/images/';
         if (!is_dir($imagePath)) {
             GeneralUtility::mkdir_deep($imagePath);
         }
diff --git a/typo3/sysext/install/Classes/Controller/UpgradeController.php b/typo3/sysext/install/Classes/Controller/UpgradeController.php
index a1e55501b5ea..f76567433a1f 100644
--- a/typo3/sysext/install/Classes/Controller/UpgradeController.php
+++ b/typo3/sysext/install/Classes/Controller/UpgradeController.php
@@ -181,7 +181,7 @@ class UpgradeController extends AbstractController
             'coreUpdateEnabled' => $coreUpdateService->isCoreUpdateEnabled(),
             'coreUpdateComposerMode' => Environment::isComposerMode(),
             'coreUpdateIsReleasedVersion' => $coreVersionService->isInstalledVersionAReleasedVersion(),
-            'coreUpdateIsSymLinkedCore' => is_link(PATH_site . 'typo3_src'),
+            'coreUpdateIsSymLinkedCore' => is_link(Environment::getPublicPath() . '/typo3_src'),
 
             'upgradeWizardsMarkUndoneToken' => $formProtection->generateToken('installTool', 'upgradeWizardsMarkUndone'),
             'upgradeWizardsInputToken' => $formProtection->generateToken('installTool', 'upgradeWizardsInput'),
@@ -474,7 +474,7 @@ class UpgradeController extends AbstractController
      */
     public function extensionScannerGetDataAction(ServerRequestInterface $request): ResponseInterface
     {
-        $extensionsInTypo3conf = (new Finder())->directories()->in(PATH_site . 'typo3conf/ext')->depth(0)->sortByName();
+        $extensionsInTypo3conf = (new Finder())->directories()->in(Environment::getPublicPath() . '/typo3conf/ext')->depth(0)->sortByName();
         $view = $this->initializeStandaloneView($request, 'Upgrade/ExtensionScanner.html');
         $formProtection = FormProtectionFactory::get(InstallToolFormProtection::class);
         $view->assignMultiple([
@@ -499,7 +499,7 @@ class UpgradeController extends AbstractController
     {
         // Get and validate path
         $extension = $request->getParsedBody()['install']['extension'];
-        $extensionBasePath = PATH_site . 'typo3conf/ext/' . $extension;
+        $extensionBasePath = Environment::getPublicPath() . '/typo3conf/ext/' . $extension;
         if (empty($extension) || !GeneralUtility::isAllowedAbsPath($extensionBasePath)) {
             throw new \RuntimeException(
                 'Path to extension ' . $extension . ' not allowed.',
@@ -583,7 +583,7 @@ class UpgradeController extends AbstractController
     {
         // Get and validate path and file
         $extension = $request->getParsedBody()['install']['extension'];
-        $extensionBasePath = PATH_site . 'typo3conf/ext/' . $extension;
+        $extensionBasePath = Environment::getPublicPath() . '/typo3conf/ext/' . $extension;
         if (empty($extension) || !GeneralUtility::isAllowedAbsPath($extensionBasePath)) {
             throw new \RuntimeException(
                 'Path to extension ' . $extension . ' not allowed.',
diff --git a/typo3/sysext/install/Classes/FolderStructure/AbstractNode.php b/typo3/sysext/install/Classes/FolderStructure/AbstractNode.php
index 80644031e07d..75059e1f873d 100644
--- a/typo3/sysext/install/Classes/FolderStructure/AbstractNode.php
+++ b/typo3/sysext/install/Classes/FolderStructure/AbstractNode.php
@@ -199,7 +199,7 @@ abstract class AbstractNode
     }
 
     /**
-     * Cut off PATH_site from given path
+     * Cut off public web path from given path
      *
      * @param string $path Given path
      * @return string Relative path, but beginning with /
@@ -210,14 +210,14 @@ abstract class AbstractNode
         if ($path === null) {
             $path = $this->getAbsolutePath();
         }
-        $pathSiteWithoutTrailingSlash = substr(PATH_site, 0, -1);
-        if (strpos($path, $pathSiteWithoutTrailingSlash, 0) !== 0) {
+        $publicPath = Environment::getPublicPath();
+        if (strpos($path, $publicPath, 0) !== 0) {
             throw new Exception\InvalidArgumentException(
-                'PATH_site is not first part of given path',
+                'Public path is not first part of given path',
                 1366398198
             );
         }
-        $relativePath = substr($path, strlen($pathSiteWithoutTrailingSlash), strlen($path));
+        $relativePath = substr($path, strlen($publicPath), strlen($path));
         // Add a forward slash again, so we don't end up with an empty string
         if ($relativePath === '') {
             $relativePath = '/';
diff --git a/typo3/sysext/install/Classes/FolderStructure/DefaultFactory.php b/typo3/sysext/install/Classes/FolderStructure/DefaultFactory.php
index daa9c46a3455..59d56d709748 100644
--- a/typo3/sysext/install/Classes/FolderStructure/DefaultFactory.php
+++ b/typo3/sysext/install/Classes/FolderStructure/DefaultFactory.php
@@ -14,6 +14,8 @@ namespace TYPO3\CMS\Install\FolderStructure;
  * The TYPO3 project - inspiring people to share!
  */
 
+use TYPO3\CMS\Core\Core\Environment;
+
 /**
  * Factory returns default folder structure object hierarchy
  */
@@ -43,8 +45,8 @@ class DefaultFactory
         $directoryPermission = $GLOBALS['TYPO3_CONF_VARS']['SYS']['folderCreateMask'];
 
         return [
-            // Cut off trailing forward / from PATH_site, so root node has no trailing slash like all others
-            'name' => substr(PATH_site, 0, -1),
+            // Note that root node has no trailing slash like all others
+            'name' => Environment::getPublicPath(),
             'targetPermission' => $directoryPermission,
             'children' => [
                 [
@@ -99,7 +101,7 @@ class DefaultFactory
                                     'name' => '.htaccess',
                                     'type' => FileNode::class,
                                     'targetPermission' => $filePermission,
-                                    'targetContentFile' => PATH_site . 'typo3/sysext/install/Resources/Private/FolderStructureTemplateFiles/typo3temp-var-htaccess',
+                                    'targetContentFile' => Environment::getPublicPath() . '/typo3/sysext/install/Resources/Private/FolderStructureTemplateFiles/typo3temp-var-htaccess',
                                 ],
                                 [
                                     'name' => 'charset',
@@ -151,13 +153,13 @@ class DefaultFactory
                                     'name' => '.htaccess',
                                     'type' => FileNode::class,
                                     'targetPermission' => $filePermission,
-                                    'targetContentFile' => PATH_site . 'typo3/sysext/install/Resources/Private/FolderStructureTemplateFiles/fileadmin-temp-htaccess',
+                                    'targetContentFile' => Environment::getPublicPath() . '/typo3/sysext/install/Resources/Private/FolderStructureTemplateFiles/fileadmin-temp-htaccess',
                                 ],
                                 [
                                     'name' => 'index.html',
                                     'type' => FileNode::class,
                                     'targetPermission' => $filePermission,
-                                    'targetContentFile' => PATH_site . 'typo3/sysext/install/Resources/Private/FolderStructureTemplateFiles/fileadmin-temp-index.html',
+                                    'targetContentFile' => Environment::getPublicPath() . '/typo3/sysext/install/Resources/Private/FolderStructureTemplateFiles/fileadmin-temp-index.html',
                                 ],
                             ],
                         ],
@@ -186,13 +188,13 @@ class DefaultFactory
                                                     'name' => '.htaccess',
                                                     'type' => FileNode::class,
                                                     'targetPermission' => $filePermission,
-                                                    'targetContentFile' => PATH_site . 'typo3/sysext/install/Resources/Private/FolderStructureTemplateFiles/fileadmin-user_upload-temp-importexport-htaccess',
+                                                    'targetContentFile' => Environment::getPublicPath() . '/typo3/sysext/install/Resources/Private/FolderStructureTemplateFiles/fileadmin-user_upload-temp-importexport-htaccess',
                                                 ],
                                                 [
                                                     'name' => 'index.html',
                                                     'type' => FileNode::class,
                                                     'targetPermission' => $filePermission,
-                                                    'targetContentFile' => PATH_site . 'typo3/sysext/install/Resources/Private/FolderStructureTemplateFiles/fileadmin-temp-index.html',
+                                                    'targetContentFile' => Environment::getPublicPath() . '/typo3/sysext/install/Resources/Private/FolderStructureTemplateFiles/fileadmin-temp-index.html',
                                                 ],
                                             ],
                                         ],
diff --git a/typo3/sysext/install/Classes/Report/SecurityStatusReport.php b/typo3/sysext/install/Classes/Report/SecurityStatusReport.php
index e7901e1901e5..06a5af062f13 100644
--- a/typo3/sysext/install/Classes/Report/SecurityStatusReport.php
+++ b/typo3/sysext/install/Classes/Report/SecurityStatusReport.php
@@ -14,6 +14,7 @@ namespace TYPO3\CMS\Install\Report;
  * The TYPO3 project - inspiring people to share!
  */
 
+use TYPO3\CMS\Core\Core\Environment;
 use TYPO3\CMS\Core\Utility\GeneralUtility;
 use TYPO3\CMS\Install\Service\EnableFileService;
 use TYPO3\CMS\Reports\Status;
@@ -83,7 +84,7 @@ class SecurityStatusReport implements \TYPO3\CMS\Reports\StatusProviderInterface
      */
     protected function getInstallToolProtectionStatus()
     {
-        $enableInstallToolFile = PATH_site . EnableFileService::INSTALL_TOOL_ENABLE_FILE_PATH;
+        $enableInstallToolFile = Environment::getPublicPath() . '/' . EnableFileService::INSTALL_TOOL_ENABLE_FILE_PATH;
         $value = $GLOBALS['LANG']->getLL('status_disabled');
         $message = '';
         $severity = Status::OK;
diff --git a/typo3/sysext/install/Classes/Service/CoreUpdateService.php b/typo3/sysext/install/Classes/Service/CoreUpdateService.php
index 37e90e5d4a72..3ef68094033f 100644
--- a/typo3/sysext/install/Classes/Service/CoreUpdateService.php
+++ b/typo3/sysext/install/Classes/Service/CoreUpdateService.php
@@ -97,7 +97,7 @@ class CoreUpdateService
      */
     protected function discoverCurrentCoreSymlink()
     {
-        return PATH_site . 'typo3_src';
+        return Environment::getPublicPath() . '/typo3_src';
     }
 
     /**
@@ -166,7 +166,7 @@ class CoreUpdateService
         $folderStructureMessageQueue = $folderStructureFacade->getStatus();
         $folderStructureErrors = $folderStructureMessageQueue->getAllMessages(FlashMessage::ERROR);
         $folderStructureWarnings = $folderStructureMessageQueue->getAllMessages(FlashMessage::WARNING);
-        if (!empty($folderStructureErrors) || !empty($folderStructureWarnings) || !is_link(PATH_site . 'typo3_src')) {
+        if (!empty($folderStructureErrors) || !empty($folderStructureWarnings) || !is_link(Environment::getPublicPath() . '/typo3_src')) {
             $success = false;
             $this->messages->enqueue(new FlashMessage(
                 'To perform an update, the folder structure of this TYPO3 CMS instance must'
@@ -189,12 +189,12 @@ class CoreUpdateService
 
         if ($success) {
             // Explicit write check to document root
-            $file = PATH_site . StringUtility::getUniqueId('install-core-update-test-');
+            $file = Environment::getPublicPath() . '/' . StringUtility::getUniqueId('install-core-update-test-');
             $result = @touch($file);
             if (!$result) {
                 $success = false;
                 $this->messages->enqueue(new FlashMessage(
-                    'Could not write a file in path "' . PATH_site . '"!',
+                    'Could not write a file in path "' . Environment::getPublicPath() . '/"!',
                     'Automatic TYPO3 CMS core update not possible: No write access to document root',
                     FlashMessage::ERROR
                 ));
@@ -519,7 +519,7 @@ class CoreUpdateService
      */
     protected function getRelativePath($absolutePath)
     {
-        $sourcePath = explode(DIRECTORY_SEPARATOR, rtrim(PATH_site, DIRECTORY_SEPARATOR));
+        $sourcePath = explode(DIRECTORY_SEPARATOR, Environment::getPublicPath());
         $targetPath = explode(DIRECTORY_SEPARATOR, rtrim($absolutePath, DIRECTORY_SEPARATOR));
         while (count($sourcePath) && count($targetPath) && $sourcePath[0] === $targetPath[0]) {
             array_shift($sourcePath);
diff --git a/typo3/sysext/install/Classes/Service/EnableFileService.php b/typo3/sysext/install/Classes/Service/EnableFileService.php
index b387f9f70758..8f0be4a765fc 100644
--- a/typo3/sysext/install/Classes/Service/EnableFileService.php
+++ b/typo3/sysext/install/Classes/Service/EnableFileService.php
@@ -13,6 +13,7 @@ namespace TYPO3\CMS\Install\Service;
  *
  * The TYPO3 project - inspiring people to share!
  */
+use TYPO3\CMS\Core\Core\Environment;
 use TYPO3\CMS\Core\Utility\GeneralUtility;
 
 /**
@@ -35,13 +36,6 @@ class EnableFileService
      */
     const INSTALL_TOOL_ENABLE_FILE_LIFETIME = 3600;
 
-    /**
-     * Path site property, needed for unit testing
-     *
-     * @var string
-     */
-    protected static $sitePath = PATH_site;
-
     /**
      * @return bool
      */
@@ -92,7 +86,7 @@ class EnableFileService
         $result = true;
         $files = self::getFirstInstallFilePaths();
         foreach ($files as $file) {
-            $result = unlink(self::$sitePath . $file) && $result;
+            $result = unlink(Environment::getPublicPath() . '/' . $file) && $result;
         }
         return $result;
     }
@@ -181,7 +175,7 @@ class EnableFileService
      */
     protected static function getInstallToolEnableFilePath()
     {
-        return PATH_site . self::INSTALL_TOOL_ENABLE_FILE_PATH;
+        return Environment::getPublicPath() . '/' . self::INSTALL_TOOL_ENABLE_FILE_PATH;
     }
 
     /**
@@ -191,8 +185,8 @@ class EnableFileService
      */
     protected static function getFirstInstallFilePaths()
     {
-        $files = array_filter(scandir(self::$sitePath), function ($file) {
-            return @is_file(self::$sitePath . $file) && preg_match('~^' . self::FIRST_INSTALL_FILE_PATH . '.*~i', $file);
+        $files = array_filter(scandir(Environment::getPublicPath() . '/'), function ($file) {
+            return @is_file(Environment::getPublicPath() . '/' . $file) && preg_match('~^' . self::FIRST_INSTALL_FILE_PATH . '.*~i', $file);
         });
         return $files;
     }
diff --git a/typo3/sysext/install/Classes/Service/Typo3tempFileService.php b/typo3/sysext/install/Classes/Service/Typo3tempFileService.php
index 23e3838f0622..458bcf47e4ed 100644
--- a/typo3/sysext/install/Classes/Service/Typo3tempFileService.php
+++ b/typo3/sysext/install/Classes/Service/Typo3tempFileService.php
@@ -16,6 +16,7 @@ namespace TYPO3\CMS\Install\Service;
 
 use Symfony\Component\Finder\Finder;
 use Symfony\Component\Finder\SplFileInfo;
+use TYPO3\CMS\Core\Core\Environment;
 use TYPO3\CMS\Core\Resource\ProcessedFileRepository;
 use TYPO3\CMS\Core\Utility\GeneralUtility;
 
@@ -31,7 +32,7 @@ class Typo3tempFileService
      */
     public function getDirectoryStatistics()
     {
-        $basePath = PATH_site . 'typo3temp/assets';
+        $basePath = Environment::getPublicPath() . '/typo3temp/assets';
         if (!is_dir($basePath)) {
             return [];
         }
@@ -74,7 +75,7 @@ class Typo3tempFileService
      */
     public function clearAssetsFolder(string $folderName)
     {
-        $basePath = PATH_site . 'typo3temp/assets/' . $folderName;
+        $basePath = Environment::getPublicPath() . '/typo3temp/assets/' . $folderName;
         if (empty($folderName) || !GeneralUtility::isAllowedAbsPath($basePath)) {
             throw new \RuntimeException(
                 'Path to folder ' . $folderName . ' not allowed.',
diff --git a/typo3/sysext/install/Classes/Updates/BackendLayoutIconUpdateWizard.php b/typo3/sysext/install/Classes/Updates/BackendLayoutIconUpdateWizard.php
index 537965ce7e84..5cf9a0f0b32d 100644
--- a/typo3/sysext/install/Classes/Updates/BackendLayoutIconUpdateWizard.php
+++ b/typo3/sysext/install/Classes/Updates/BackendLayoutIconUpdateWizard.php
@@ -15,6 +15,7 @@ namespace TYPO3\CMS\Install\Updates;
  * The TYPO3 project - inspiring people to share!
  */
 use Doctrine\DBAL\DBALException;
+use TYPO3\CMS\Core\Core\Environment;
 use TYPO3\CMS\Core\Database\ConnectionPool;
 use TYPO3\CMS\Core\Database\Query\Expression\ExpressionBuilder;
 use TYPO3\CMS\Core\Log\Logger;
@@ -206,8 +207,8 @@ class BackendLayoutIconUpdateWizard extends AbstractUpdate
 
         foreach ($fieldItems as $item) {
             $fileUid = null;
-            $sourcePath = PATH_site . $this->sourcePath . $item;
-            $targetDirectory = PATH_site . $fileadminDirectory . $this->targetPath;
+            $sourcePath = Environment::getPublicPath() . '/' . $this->sourcePath . $item;
+            $targetDirectory = Environment::getPublicPath() . '/' . $fileadminDirectory . $this->targetPath;
             $targetPath = $targetDirectory . PathUtility::basenameDuringBootstrap($item);
 
             // maybe the file was already moved, so check if the original file still exists
diff --git a/typo3/sysext/install/Classes/Updates/FrontendUserImageUpdateWizard.php b/typo3/sysext/install/Classes/Updates/FrontendUserImageUpdateWizard.php
index eb1aef6a3d0d..2b2ff8167d38 100644
--- a/typo3/sysext/install/Classes/Updates/FrontendUserImageUpdateWizard.php
+++ b/typo3/sysext/install/Classes/Updates/FrontendUserImageUpdateWizard.php
@@ -14,6 +14,7 @@ namespace TYPO3\CMS\Install\Updates;
  * The TYPO3 project - inspiring people to share!
  */
 use Doctrine\DBAL\DBALException;
+use TYPO3\CMS\Core\Core\Environment;
 use TYPO3\CMS\Core\Database\ConnectionPool;
 use TYPO3\CMS\Core\Database\Query\Expression\ExpressionBuilder;
 use TYPO3\CMS\Core\Database\Query\Restriction\DeletedRestriction;
@@ -242,18 +243,14 @@ class FrontendUserImageUpdateWizard extends AbstractUpdate
         $fileadminDirectory = rtrim($GLOBALS['TYPO3_CONF_VARS']['BE']['fileadminDir'], '/') . '/';
         $i = 0;
 
-        if (!PATH_site) {
-            throw new \Exception('PATH_site was undefined.', 1476107387);
-        }
-
         $storageUid = (int)$this->storage->getUid();
 
         $connectionPool = GeneralUtility::makeInstance(ConnectionPool::class);
 
         foreach ($fieldItems as $item) {
             $fileUid = null;
-            $sourcePath = PATH_site . $this->sourcePath . $item;
-            $targetDirectory = PATH_site . $fileadminDirectory . $this->targetPath;
+            $sourcePath = Environment::getPublicPath() . '/' . $this->sourcePath . $item;
+            $targetDirectory = Environment::getPublicPath() . '/' . $fileadminDirectory . $this->targetPath;
             $targetPath = $targetDirectory . PathUtility::basename($item);
 
             // maybe the file was already moved, so check if the original file still exists
diff --git a/typo3/sysext/install/Resources/Private/Templates/Environment/FolderStructure.html b/typo3/sysext/install/Resources/Private/Templates/Environment/FolderStructure.html
index 193e61a55d12..3e25dcfba6bb 100644
--- a/typo3/sysext/install/Resources/Private/Templates/Environment/FolderStructure.html
+++ b/typo3/sysext/install/Resources/Private/Templates/Environment/FolderStructure.html
@@ -1,6 +1,5 @@
-{namespace i=TYPO3\CMS\Install\ViewHelpers}
 <p>
-	Root Directory: <strong><i:constant name="PATH_site"/></strong>
+	Root Directory: <strong>{publicPath}</strong>
 </p>
 
 <div class="t3js-folderStructure-output"></div>
diff --git a/typo3/sysext/install/Tests/Unit/FolderStructure/AbstractNodeTest.php b/typo3/sysext/install/Tests/Unit/FolderStructure/AbstractNodeTest.php
index af7ce6961255..7081ed408111 100644
--- a/typo3/sysext/install/Tests/Unit/FolderStructure/AbstractNodeTest.php
+++ b/typo3/sysext/install/Tests/Unit/FolderStructure/AbstractNodeTest.php
@@ -14,6 +14,7 @@ namespace TYPO3\CMS\Install\Tests\Unit\FolderStructure;
  * The TYPO3 project - inspiring people to share!
  */
 
+use TYPO3\CMS\Core\Core\Environment;
 use TYPO3\CMS\Core\Messaging\FlashMessage;
 use TYPO3\CMS\Install\FolderStructure\AbstractNode;
 use TYPO3\CMS\Install\FolderStructure\Exception;
@@ -136,8 +137,8 @@ class AbstractNodeTest extends FolderStructureTestCase
     {
         /** @var $node AbstractNode|AccessibleObjectInterface|\PHPUnit_Framework_MockObject_MockObject */
         $node = $this->getAccessibleMock(AbstractNode::class, ['getAbsolutePath'], [], '', false);
-        $path = PATH_site . 'typo3temp/var/tests/' . $this->getUniqueId('link_');
-        $target = PATH_site . 'typo3temp/var/tests/' . $this->getUniqueId('notExists_');
+        $path = Environment::getVarPath() . '/tests/' . $this->getUniqueId('link_');
+        $target = Environment::getVarPath() . '/tests/' . $this->getUniqueId('notExists_');
         touch($target);
         symlink($target, $path);
         unlink($target);
@@ -338,7 +339,7 @@ class AbstractNodeTest extends FolderStructureTestCase
             '',
             false
         );
-        $node->expects($this->once())->method('getAbsolutePath')->will($this->returnValue(PATH_site));
+        $node->expects($this->once())->method('getAbsolutePath')->will($this->returnValue(Environment::getPublicPath()));
         $node->_call('getRelativePathBelowSiteRoot', null);
     }
 
@@ -349,7 +350,7 @@ class AbstractNodeTest extends FolderStructureTestCase
     {
         /** @var $node AbstractNode|AccessibleObjectInterface|\PHPUnit_Framework_MockObject_MockObject */
         $node = $this->getAccessibleMock(AbstractNode::class, ['dummy'], [], '', false);
-        $result = $node->_call('getRelativePathBelowSiteRoot', PATH_site);
+        $result = $node->_call('getRelativePathBelowSiteRoot', Environment::getPublicPath() . '/');
         $this->assertSame('/', $result);
     }
 
@@ -360,7 +361,7 @@ class AbstractNodeTest extends FolderStructureTestCase
     {
         /** @var $node AbstractNode|AccessibleObjectInterface|\PHPUnit_Framework_MockObject_MockObject */
         $node = $this->getAccessibleMock(AbstractNode::class, ['dummy'], [], '', false);
-        $result = $node->_call('getRelativePathBelowSiteRoot', PATH_site . 'foo/bar');
+        $result = $node->_call('getRelativePathBelowSiteRoot', Environment::getPublicPath() . '/foo/bar');
         $this->assertSame('/foo/bar', $result);
     }
 }
diff --git a/typo3/sysext/install/Tests/Unit/FolderStructure/DirectoryNodeTest.php b/typo3/sysext/install/Tests/Unit/FolderStructure/DirectoryNodeTest.php
index b163ac6cfaa7..4cd16c21bfb4 100644
--- a/typo3/sysext/install/Tests/Unit/FolderStructure/DirectoryNodeTest.php
+++ b/typo3/sysext/install/Tests/Unit/FolderStructure/DirectoryNodeTest.php
@@ -14,6 +14,7 @@ namespace TYPO3\CMS\Install\Tests\Unit\FolderStructure;
  * The TYPO3 project - inspiring people to share!
  */
 
+use TYPO3\CMS\Core\Core\Environment;
 use TYPO3\CMS\Core\Messaging\FlashMessage;
 use TYPO3\CMS\Install\FolderStructure\DirectoryNode;
 use TYPO3\CMS\Install\FolderStructure\Exception;
@@ -631,7 +632,7 @@ class DirectoryNodeTest extends FolderStructureTestCase
     {
         /** @var $node DirectoryNode|AccessibleObjectInterface|\PHPUnit_Framework_MockObject_MockObject */
         $node = $this->getAccessibleMock(DirectoryNode::class, ['getAbsolutePath'], [], '', false);
-        $path = PATH_site . 'typo3temp/var/tests/' . $this->getUniqueId('root_');
+        $path = Environment::getVarPath() . '/tests/' . $this->getUniqueId('root_');
         \TYPO3\CMS\Core\Utility\GeneralUtility::mkdir_deep($path);
         $this->testFilesToDelete[] = $path;
         $link = $this->getUniqueId('link_');
diff --git a/typo3/sysext/install/Tests/Unit/FolderStructure/FileNodeTest.php b/typo3/sysext/install/Tests/Unit/FolderStructure/FileNodeTest.php
index b1a2f70b7498..7172e8884e92 100644
--- a/typo3/sysext/install/Tests/Unit/FolderStructure/FileNodeTest.php
+++ b/typo3/sysext/install/Tests/Unit/FolderStructure/FileNodeTest.php
@@ -14,6 +14,7 @@ namespace TYPO3\CMS\Install\Tests\Unit\FolderStructure;
  * The TYPO3 project - inspiring people to share!
  */
 
+use TYPO3\CMS\Core\Core\Environment;
 use TYPO3\CMS\Core\Messaging\FlashMessage;
 use TYPO3\CMS\Install\FolderStructure\Exception;
 use TYPO3\CMS\Install\FolderStructure\Exception\InvalidArgumentException;
@@ -199,7 +200,7 @@ class FileNodeTest extends FolderStructureTestCase
             '',
             false
         );
-        $path = PATH_site . 'typo3temp/var/tests/' . $this->getUniqueId('dir_');
+        $path = Environment::getVarPath() . '/tests/' . $this->getUniqueId('dir_');
         $node->expects($this->any())->method('getAbsolutePath')->will($this->returnValue($path));
         $node->expects($this->any())->method('exists')->will($this->returnValue(true));
         $node->expects($this->any())->method('isFile')->will($this->returnValue(true));
@@ -776,7 +777,7 @@ class FileNodeTest extends FolderStructureTestCase
     {
         /** @var $node FileNode|AccessibleObjectInterface|\PHPUnit_Framework_MockObject_MockObject */
         $node = $this->getAccessibleMock(FileNode::class, ['getAbsolutePath'], [], '', false);
-        $path = PATH_site . 'typo3temp/var/tests/' . $this->getUniqueId('root_');
+        $path = Environment::getVarPath() . '/tests/' . $this->getUniqueId('root_');
         \TYPO3\CMS\Core\Utility\GeneralUtility::mkdir_deep($path);
         $this->testFilesToDelete[] = $path;
         $link = $this->getUniqueId('link_');
diff --git a/typo3/sysext/install/Tests/Unit/FolderStructure/LinkNodeTest.php b/typo3/sysext/install/Tests/Unit/FolderStructure/LinkNodeTest.php
index 6fe092c2954c..7f9bf95469c9 100644
--- a/typo3/sysext/install/Tests/Unit/FolderStructure/LinkNodeTest.php
+++ b/typo3/sysext/install/Tests/Unit/FolderStructure/LinkNodeTest.php
@@ -15,6 +15,7 @@ namespace TYPO3\CMS\Install\Tests\Unit\FolderStructure;
  * The TYPO3 project - inspiring people to share!
  */
 
+use TYPO3\CMS\Core\Core\Environment;
 use TYPO3\CMS\Core\Messaging\FlashMessage;
 use TYPO3\CMS\Install\FolderStructure\Exception\InvalidArgumentException;
 use TYPO3\CMS\Install\FolderStructure\LinkNode;
@@ -111,7 +112,7 @@ class LinkNodeTest extends UnitTestCase
             '',
             false
         );
-        $path = PATH_site . 'typo3temp/var/tests/' . $this->getUniqueId('dir_');
+        $path = Environment::getVarPath() . '/tests/' . $this->getUniqueId('dir_');
         $node->expects($this->any())->method('getAbsolutePath')->will($this->returnValue($path));
         $this->assertInternalType('array', $node->getStatus());
     }
@@ -129,7 +130,7 @@ class LinkNodeTest extends UnitTestCase
             '',
             false
         );
-        $path = PATH_site . 'typo3temp/var/tests/' . $this->getUniqueId('dir_');
+        $path = Environment::getVarPath() . '/tests/' . $this->getUniqueId('dir_');
         $node->expects($this->any())->method('getAbsolutePath')->will($this->returnValue($path));
         $node->expects($this->once())->method('isWindowsOs')->will($this->returnValue(true));
         $statusArray = $node->getStatus();
@@ -149,7 +150,7 @@ class LinkNodeTest extends UnitTestCase
             '',
             false
         );
-        $path = PATH_site . 'typo3temp/var/tests/' . $this->getUniqueId('dir_');
+        $path = Environment::getVarPath() . '/tests/' . $this->getUniqueId('dir_');
         $node->expects($this->any())->method('getAbsolutePath')->will($this->returnValue($path));
         $node->expects($this->any())->method('isWindowsOs')->will($this->returnValue(false));
         $node->expects($this->once())->method('exists')->will($this->returnValue(false));
@@ -258,8 +259,8 @@ class LinkNodeTest extends UnitTestCase
     {
         /** @var $node LinkNode|AccessibleObjectInterface|\PHPUnit_Framework_MockObject_MockObject */
         $node = $this->getAccessibleMock(LinkNode::class, ['exists', 'getAbsolutePath'], [], '', false);
-        $path = PATH_site . 'typo3temp/var/tests/' . $this->getUniqueId('link_');
-        $target = PATH_site . 'typo3temp/var/tests/' . $this->getUniqueId('linkTarget_');
+        $path = Environment::getVarPath() . '/tests/' . $this->getUniqueId('link_');
+        $target = Environment::getVarPath() . '/tests/' . $this->getUniqueId('linkTarget_');
         touch($target);
         symlink($target, $path);
         $this->testFilesToDelete[] = $path;
@@ -276,7 +277,7 @@ class LinkNodeTest extends UnitTestCase
     {
         /** @var $node LinkNode|AccessibleObjectInterface|\PHPUnit_Framework_MockObject_MockObject */
         $node = $this->getAccessibleMock(LinkNode::class, ['exists', 'getAbsolutePath'], [], '', false);
-        $path = PATH_site . 'typo3temp/var/tests/' . $this->getUniqueId('file_');
+        $path = Environment::getVarPath() . '/tests/' . $this->getUniqueId('file_');
         touch($path);
         $this->testFilesToDelete[] = $path;
         $node->expects($this->any())->method('exists')->will($this->returnValue(true));
@@ -344,8 +345,8 @@ class LinkNodeTest extends UnitTestCase
      */
     public function isTargetCorrectReturnsTrueIfActualTargetIsIdenticalToSpecifiedTarget()
     {
-        $path = PATH_site . 'typo3temp/var/tests/' . $this->getUniqueId('link_');
-        $target = PATH_site . 'typo3temp/var/tests/' . $this->getUniqueId('linkTarget_');
+        $path = Environment::getVarPath() . '/tests/' . $this->getUniqueId('link_');
+        $target = Environment::getVarPath() . '/tests/' . $this->getUniqueId('linkTarget_');
         touch($target);
         symlink($target, $path);
         $this->testFilesToDelete[] = $path;
@@ -371,8 +372,8 @@ class LinkNodeTest extends UnitTestCase
      */
     public function isTargetCorrectReturnsFalseIfActualTargetIsNotIdenticalToSpecifiedTarget()
     {
-        $path = PATH_site . 'typo3temp/var/tests/' . $this->getUniqueId('link_');
-        $target = PATH_site . 'typo3temp/var/tests/' . $this->getUniqueId('linkTarget_');
+        $path = Environment::getVarPath() . '/tests/' . $this->getUniqueId('link_');
+        $target = Environment::getVarPath() . '/tests/' . $this->getUniqueId('linkTarget_');
         touch($target);
         symlink($target, $path);
         $this->testFilesToDelete[] = $path;
diff --git a/typo3/sysext/install/Tests/Unit/FolderStructure/RootNodeTest.php b/typo3/sysext/install/Tests/Unit/FolderStructure/RootNodeTest.php
index 9ed9a944d466..3b518b755224 100644
--- a/typo3/sysext/install/Tests/Unit/FolderStructure/RootNodeTest.php
+++ b/typo3/sysext/install/Tests/Unit/FolderStructure/RootNodeTest.php
@@ -14,6 +14,7 @@ namespace TYPO3\CMS\Install\Tests\Unit\FolderStructure;
  * The TYPO3 project - inspiring people to share!
  */
 
+use TYPO3\CMS\Core\Core\Environment;
 use TYPO3\CMS\Core\Messaging\FlashMessage;
 use TYPO3\CMS\Install\FolderStructure\DirectoryNode;
 use TYPO3\CMS\Install\FolderStructure\Exception\InvalidArgumentException;
@@ -189,7 +190,7 @@ class RootNodeTest extends UnitTestCase
             '',
             false
         );
-        $path = PATH_site . 'typo3temp/var/tests/' . $this->getUniqueId('dir_');
+        $path = Environment::getVarPath() . '/tests/' . $this->getUniqueId('dir_');
         touch($path);
         $this->testFilesToDelete[] = $path;
         $node->expects($this->any())->method('getAbsolutePath')->will($this->returnValue($path));
@@ -214,7 +215,7 @@ class RootNodeTest extends UnitTestCase
             '',
             false
         );
-        $path = PATH_site . 'typo3temp/var/tests/' . $this->getUniqueId('dir_');
+        $path = Environment::getVarPath() . '/tests/' . $this->getUniqueId('dir_');
         touch($path);
         $this->testFilesToDelete[] = $path;
         $node->expects($this->any())->method('getAbsolutePath')->will($this->returnValue($path));
diff --git a/typo3/sysext/install/Tests/Unit/Service/EnableFileServiceTest.php b/typo3/sysext/install/Tests/Unit/Service/EnableFileServiceTest.php
index fe78655be2a3..afcfcf70183f 100644
--- a/typo3/sysext/install/Tests/Unit/Service/EnableFileServiceTest.php
+++ b/typo3/sysext/install/Tests/Unit/Service/EnableFileServiceTest.php
@@ -15,13 +15,21 @@ namespace TYPO3\CMS\Install\Tests\Unit\Service;
  */
 
 use org\bovigo\vfs\vfsStream;
+use TYPO3\CMS\Core\Core\Environment;
 use TYPO3\CMS\Install\Service\EnableFileService;
+use TYPO3\TestingFramework\Core\AccessibleObjectInterface;
+use TYPO3\TestingFramework\Core\Unit\UnitTestCase;
 
 /**
  * Test case
  */
-class EnableFileServiceTest extends \TYPO3\TestingFramework\Core\Unit\UnitTestCase
+class EnableFileServiceTest extends UnitTestCase
 {
+    /**
+     * @var bool This test fiddles with Environment
+     */
+    protected $backupEnvironment = true;
+
     /**
      * Data provider
      *
@@ -67,10 +75,20 @@ class EnableFileServiceTest extends \TYPO3\TestingFramework\Core\Unit\UnitTestCa
     {
         $vfs = vfsStream::setup('root');
         vfsStream::create($structure, $vfs);
-        /** @var $instance EnableFileService|\TYPO3\TestingFramework\Core\AccessibleObjectInterface|\PHPUnit_Framework_MockObject_MockObject */
-        $instance = $this->getAccessibleMock(EnableFileService::class, ['dummy'], [], '', false);
-        $instance->_setStatic('sitePath', 'vfs://root/');
-        $this->assertEquals([], array_diff($expected, $instance->_call('getFirstInstallFilePaths')));
+        /** @var $subject EnableFileService|AccessibleObjectInterface|\PHPUnit_Framework_MockObject_MockObject */
+        $subject = $this->getAccessibleMock(EnableFileService::class, ['dummy'], [], '', false);
+        Environment::initialize(
+            Environment::getContext(),
+            Environment::isCli(),
+            Environment::isComposerMode(),
+            Environment::getProjectPath(),
+            'vfs://root',
+            Environment::getVarPath(),
+            Environment::getConfigPath(),
+            Environment::getCurrentScript(),
+            'UNIX'
+        );
+        $this->assertEquals([], array_diff($expected, $subject->_call('getFirstInstallFilePaths')));
     }
 
     /**
@@ -129,10 +147,20 @@ class EnableFileServiceTest extends \TYPO3\TestingFramework\Core\Unit\UnitTestCa
     {
         $vfs = vfsStream::setup('root');
         vfsStream::create($structure, $vfs);
-        /** @var $instance EnableFileService|\TYPO3\TestingFramework\Core\AccessibleObjectInterface|\PHPUnit_Framework_MockObject_MockObject */
-        $instance = $this->getAccessibleMock(EnableFileService::class, ['dummy'], [], '', false);
-        $instance->_setStatic('sitePath', 'vfs://root/');
-        $instance->_call('removeFirstInstallFile');
+        /** @var $subject EnableFileService|AccessibleObjectInterface|\PHPUnit_Framework_MockObject_MockObject */
+        $subject = $this->getAccessibleMock(EnableFileService::class, ['dummy'], [], '', false);
+        Environment::initialize(
+            Environment::getContext(),
+            Environment::isCli(),
+            Environment::isComposerMode(),
+            Environment::getProjectPath(),
+            'vfs://root',
+            Environment::getVarPath(),
+            Environment::getConfigPath(),
+            Environment::getCurrentScript(),
+            'UNIX'
+        );
+        $subject->_call('removeFirstInstallFile');
 
         $this->assertEquals([], array_diff($expected, scandir('vfs://root/')));
     }
-- 
GitLab