Commit f22fa503 authored by Christian Kuhn's avatar Christian Kuhn Committed by Benni Mack
Browse files

[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: default avatarTYPO3com <no-reply@typo3.com>
Reviewed-by: Jan Helke's avatarJan Helke <typo3@helke.de>
Tested-by: Jan Helke's avatarJan Helke <typo3@helke.de>
Reviewed-by: Benni Mack's avatarBenni Mack <benni@typo3.org>
Tested-by: Benni Mack's avatarBenni Mack <benni@typo3.org>
parent 506e6e53
......@@ -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);
}
......
......@@ -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.',
......
......@@ -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 = '/';
......
......@@ -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',
],
],
],
......
......@@ -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;
......
......@@ -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);
......
......@@ -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;
}
......
......@@ -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.',
......
......@@ -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
......
......@@ -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
......
{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>
......
......@@ -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()));