diff --git a/typo3/sysext/extensionmanager/Classes/Utility/EmConfUtility.php b/typo3/sysext/extensionmanager/Classes/Utility/EmConfUtility.php index 4b6295fcedd66ae4cb7dfd2343adaa0bcaf55f92..4815f236e6fadd43e455966532d34e75165b8d63 100644 --- a/typo3/sysext/extensionmanager/Classes/Utility/EmConfUtility.php +++ b/typo3/sysext/extensionmanager/Classes/Utility/EmConfUtility.php @@ -14,10 +14,13 @@ namespace TYPO3\CMS\Extensionmanager\Utility; * The TYPO3 project - inspiring people to share! */ +use TYPO3\CMS\Core\Core\Environment; +use TYPO3\CMS\Core\SingletonInterface; + /** * Utility for dealing with ext_emconf */ -class EmConfUtility implements \TYPO3\CMS\Core\SingletonInterface +class EmConfUtility implements SingletonInterface { /** * Returns the $EM_CONF array from an extensions ext_emconf.php file @@ -28,7 +31,7 @@ class EmConfUtility implements \TYPO3\CMS\Core\SingletonInterface public function includeEmConf(array $extension) { $_EXTKEY = $extension['key']; - $path = PATH_site . $extension['siteRelPath'] . 'ext_emconf.php'; + $path = Environment::getPublicPath() . '/' . $extension['siteRelPath'] . 'ext_emconf.php'; $EM_CONF = null; if (file_exists($path)) { include $path; diff --git a/typo3/sysext/extensionmanager/Classes/Utility/FileHandlingUtility.php b/typo3/sysext/extensionmanager/Classes/Utility/FileHandlingUtility.php index 38ca3f3609ee65400a29eec093ee165df55abdf0..7e6650a7fc45270b78943dcc0579d0399f0f06ec 100644 --- a/typo3/sysext/extensionmanager/Classes/Utility/FileHandlingUtility.php +++ b/typo3/sysext/extensionmanager/Classes/Utility/FileHandlingUtility.php @@ -357,7 +357,7 @@ class FileHandlingUtility implements \TYPO3\CMS\Core\SingletonInterface */ protected function getAbsolutePath($relativePath) { - $absolutePath = GeneralUtility::getFileAbsFileName(GeneralUtility::resolveBackPath(PATH_site . $relativePath)); + $absolutePath = GeneralUtility::getFileAbsFileName(GeneralUtility::resolveBackPath(Environment::getPublicPath() . '/' . $relativePath)); if (empty($absolutePath)) { throw new ExtensionManagerException('Illegal relative path given', 1350742864); } diff --git a/typo3/sysext/extensionmanager/Classes/Utility/InstallUtility.php b/typo3/sysext/extensionmanager/Classes/Utility/InstallUtility.php index b176edc1914895858e7d3a9df324df60ed1a4d7f..b94c742b2922bba5d426b1b479d1031f2feab54f 100644 --- a/typo3/sysext/extensionmanager/Classes/Utility/InstallUtility.php +++ b/typo3/sysext/extensionmanager/Classes/Utility/InstallUtility.php @@ -15,6 +15,7 @@ namespace TYPO3\CMS\Extensionmanager\Utility; */ use TYPO3\CMS\Core\Configuration\ExtensionConfiguration; +use TYPO3\CMS\Core\Core\Environment; use TYPO3\CMS\Core\Database\Schema\SchemaMigrator; use TYPO3\CMS\Core\Database\Schema\SqlReader; use TYPO3\CMS\Core\Service\OpcodeCacheService; @@ -353,7 +354,7 @@ class InstallUtility implements \TYPO3\CMS\Core\SingletonInterface */ public function processDatabaseUpdates(array $extension) { - $extTablesSqlFile = PATH_site . $extension['siteRelPath'] . 'ext_tables.sql'; + $extTablesSqlFile = Environment::getPublicPath() . '/' . $extension['siteRelPath'] . 'ext_tables.sql'; $extTablesSqlContent = ''; if (file_exists($extTablesSqlFile)) { $extTablesSqlContent .= file_get_contents($extTablesSqlFile); @@ -564,7 +565,7 @@ class InstallUtility implements \TYPO3\CMS\Core\SingletonInterface $extensionSiteRelPath . 'Initialisation/data.xml' ]; foreach ($possibleImportFiles as $possibleImportFile) { - if (!file_exists(PATH_site . $possibleImportFile)) { + if (!file_exists(Environment::getPublicPath() . '/' . $possibleImportFile)) { continue; } $importFileToUse = $possibleImportFile; @@ -573,7 +574,7 @@ class InstallUtility implements \TYPO3\CMS\Core\SingletonInterface /** @var ImportExportUtility $importExportUtility */ $importExportUtility = $this->objectManager->get(ImportExportUtility::class); try { - $importResult = $importExportUtility->importT3DFile(PATH_site . $importFileToUse, 0); + $importResult = $importExportUtility->importT3DFile(Environment::getPublicPath() . '/' . $importFileToUse, 0); $this->registry->set('extensionDataImport', $extensionSiteRelPath . 'Initialisation/dataImported', 1); $this->emitAfterExtensionT3DImportSignal($importFileToUse, $importResult); } catch (\ErrorException $e) { @@ -605,7 +606,7 @@ class InstallUtility implements \TYPO3\CMS\Core\SingletonInterface { $extTablesStaticSqlRelFile = $extensionSiteRelPath . 'ext_tables_static+adt.sql'; if (!$this->registry->get('extensionDataImport', $extTablesStaticSqlRelFile)) { - $extTablesStaticSqlFile = PATH_site . $extTablesStaticSqlRelFile; + $extTablesStaticSqlFile = Environment::getPublicPath() . '/' . $extTablesStaticSqlRelFile; $shortFileHash = ''; if (file_exists($extTablesStaticSqlFile)) { $extTablesStaticSqlContent = file_get_contents($extTablesStaticSqlFile); @@ -638,10 +639,10 @@ class InstallUtility implements \TYPO3\CMS\Core\SingletonInterface { $importRelFolder = $extensionSiteRelPath . 'Initialisation/Files'; if (!$this->registry->get('extensionDataImport', $importRelFolder)) { - $importFolder = PATH_site . $importRelFolder; + $importFolder = Environment::getPublicPath() . '/' . $importRelFolder; if (file_exists($importFolder)) { $destinationRelPath = $GLOBALS['TYPO3_CONF_VARS']['BE']['fileadminDir'] . $extensionKey; - $destinationAbsolutePath = PATH_site . $destinationRelPath; + $destinationAbsolutePath = Environment::getPublicPath() . '/' . $destinationRelPath; if (!file_exists($destinationAbsolutePath) && GeneralUtility::isAllowedAbsPath($destinationAbsolutePath) ) { diff --git a/typo3/sysext/extensionmanager/Classes/Utility/ListUtility.php b/typo3/sysext/extensionmanager/Classes/Utility/ListUtility.php index e487f5e53e7501869070d70f6e64c3e3d41365ea..112548b3bd9b60dcfb3650018bad152477ab10b3 100644 --- a/typo3/sysext/extensionmanager/Classes/Utility/ListUtility.php +++ b/typo3/sysext/extensionmanager/Classes/Utility/ListUtility.php @@ -14,6 +14,7 @@ namespace TYPO3\CMS\Extensionmanager\Utility; * The TYPO3 project - inspiring people to share! */ +use TYPO3\CMS\Core\Core\Environment; use TYPO3\CMS\Core\Package\PackageInterface; use TYPO3\CMS\Core\Type\File\ImageInfo; use TYPO3\CMS\Core\Utility\ExtensionManagementUtility; @@ -114,7 +115,7 @@ class ListUtility implements \TYPO3\CMS\Core\SingletonInterface foreach ($this->packageManager->getAvailablePackages() as $package) { $installationType = $this->getInstallTypeForPackage($package); $this->availableExtensions[$package->getPackageKey()] = [ - 'siteRelPath' => str_replace(PATH_site, '', $package->getPackagePath()), + 'siteRelPath' => str_replace(Environment::getPublicPath() . '/', '', $package->getPackagePath()), 'type' => $installationType, 'key' => $package->getPackageKey(), 'ext_icon' => ExtensionManagementUtility::getExtensionIcon($package->getPackagePath()), @@ -269,7 +270,7 @@ class ListUtility implements \TYPO3\CMS\Core\SingletonInterface public function enrichExtensionsWithIconInformation(array $extensions) { foreach ($extensions as &$properties) { - $extIconPath = PATH_site . $properties['siteRelPath'] . $properties['ext_icon']; + $extIconPath = Environment::getPublicPath() . '/' . $properties['siteRelPath'] . $properties['ext_icon']; $imageInfo = GeneralUtility::makeInstance(ImageInfo::class, $extIconPath); $properties['ext_icon_width'] = $imageInfo->getWidth(); $properties['ext_icon_height'] = $imageInfo->getHeight(); diff --git a/typo3/sysext/extensionmanager/Classes/ViewHelpers/ReloadSqlDataViewHelper.php b/typo3/sysext/extensionmanager/Classes/ViewHelpers/ReloadSqlDataViewHelper.php index 279a7d151b31ac1d0eeee6effdbb8c1d62b326de..227bf03e1471e5a6f0dfc482d13ed52914e85c7a 100644 --- a/typo3/sysext/extensionmanager/Classes/ViewHelpers/ReloadSqlDataViewHelper.php +++ b/typo3/sysext/extensionmanager/Classes/ViewHelpers/ReloadSqlDataViewHelper.php @@ -14,6 +14,7 @@ namespace TYPO3\CMS\Extensionmanager\ViewHelpers; * The TYPO3 project - inspiring people to share! */ +use TYPO3\CMS\Core\Core\Environment; use TYPO3\CMS\Core\Imaging\Icon; use TYPO3\CMS\Core\Imaging\IconFactory; use TYPO3\CMS\Core\Registry; @@ -48,7 +49,7 @@ class ReloadSqlDataViewHelper extends ActionViewHelper $iconFactory = GeneralUtility::makeInstance(IconFactory::class); $staticSqlDataFile = $extension['siteRelPath'] . 'ext_tables_static+adt.sql'; - if (!file_exists(PATH_site . $staticSqlDataFile)) { + if (!file_exists(Environment::getPublicPath() . '/' . $staticSqlDataFile)) { return '<span class="btn btn-default disabled">' . $iconFactory->getIcon('empty-empty', Icon::SIZE_SMALL)->render() . '</span>'; } @@ -59,7 +60,7 @@ class ReloadSqlDataViewHelper extends ActionViewHelper // We used to only store "1" in the database when data was imported // No need to compare file content here and just show the reload icon if (!empty($oldMd5Hash) && $oldMd5Hash !== 1) { - $currentMd5Hash = md5_file(PATH_site . $staticSqlDataFile); + $currentMd5Hash = md5_file(Environment::getPublicPath() . '/' . $staticSqlDataFile); $md5HashIsEqual = $oldMd5Hash === $currentMd5Hash; } diff --git a/typo3/sysext/extensionmanager/Tests/Unit/Utility/FileHandlingUtilityTest.php b/typo3/sysext/extensionmanager/Tests/Unit/Utility/FileHandlingUtilityTest.php index e45c2f2aff029377045b1dc96fe150451917c47f..79ff414b674f878214966b77a763807c153a79b0 100644 --- a/typo3/sysext/extensionmanager/Tests/Unit/Utility/FileHandlingUtilityTest.php +++ b/typo3/sysext/extensionmanager/Tests/Unit/Utility/FileHandlingUtilityTest.php @@ -42,7 +42,7 @@ class FileHandlingUtilityTest extends UnitTestCase protected function createFakeExtension($extkeyOnly = false) { $extKey = strtolower($this->getUniqueId('testing')); - $absExtPath = PATH_site . 'typo3temp/var/tests/ext-' . $extKey . '/'; + $absExtPath = Environment::getVarPath() . '/tests/ext-' . $extKey . '/'; $relPath = 'typo3temp/var/tests/ext-' . $extKey . '/'; $this->fakedExtensions[$extKey] = [ 'siteRelPath' => $relPath, @@ -52,7 +52,7 @@ class FileHandlingUtilityTest extends UnitTestCase return $extKey; } GeneralUtility::mkdir($absExtPath); - $this->testFilesToDelete[] = PATH_site . 'typo3temp/var/tests/ext-' . $extKey; + $this->testFilesToDelete[] = Environment::getVarPath() . '/tests/ext-' . $extKey; return $extKey; } @@ -65,10 +65,10 @@ class FileHandlingUtilityTest extends UnitTestCase $fileHandlerMock = $this->getAccessibleMock(FileHandlingUtility::class, ['removeDirectory', 'addDirectory', 'getExtensionDir'], [], '', false); $fileHandlerMock->expects($this->once()) ->method('removeDirectory') - ->with(PATH_site . 'typo3temp/var/tests/ext-' . $extKey . '/'); + ->with(Environment::getVarPath() . '/tests/ext-' . $extKey . '/'); $fileHandlerMock->expects($this->any()) ->method('getExtensionDir') - ->willReturn(PATH_site . 'typo3temp/var/tests/ext-' . $extKey . '/'); + ->willReturn(Environment::getVarPath() . '/tests/ext-' . $extKey . '/'); $fileHandlerMock->_call('makeAndClearExtensionDir', $extKey); } @@ -104,8 +104,8 @@ class FileHandlingUtilityTest extends UnitTestCase public function validRelativePathDataProvider() { return [ - ['foo/../bar', PATH_site . 'bar'], - ['bas', PATH_site . 'bas'], + ['foo/../bar', Environment::getPublicPath() . '/bar'], + ['bas', Environment::getPublicPath() . '/bas'], ]; } @@ -130,10 +130,10 @@ class FileHandlingUtilityTest extends UnitTestCase $fileHandlerMock = $this->getAccessibleMock(FileHandlingUtility::class, ['removeDirectory', 'addDirectory', 'getExtensionDir']); $fileHandlerMock->expects($this->once()) ->method('addDirectory') - ->with(PATH_site . 'typo3temp/var/tests/ext-' . $extKey . '/'); + ->with(Environment::getVarPath() . '/tests/ext-' . $extKey . '/'); $fileHandlerMock->expects($this->any()) ->method('getExtensionDir') - ->willReturn(PATH_site . 'typo3temp/var/tests/ext-' . $extKey . '/'); + ->willReturn(Environment::getVarPath() . '/tests/ext-' . $extKey . '/'); $fileHandlerMock->_call('makeAndClearExtensionDir', $extKey); } @@ -155,7 +155,7 @@ class FileHandlingUtilityTest extends UnitTestCase */ public function addDirectoryAddsDirectory() { - $extDirPath = PATH_site . '/typo3temp/var/tests/' . $this->getUniqueId('test-extensions-'); + $extDirPath = Environment::getVarPath() . '/tests/' . $this->getUniqueId('test-extensions-'); $this->testFilesToDelete[] = $extDirPath; $fileHandlerMock = $this->getAccessibleMock(FileHandlingUtility::class, ['dummy']); $fileHandlerMock->_call('addDirectory', $extDirPath); @@ -167,7 +167,7 @@ class FileHandlingUtilityTest extends UnitTestCase */ public function removeDirectoryRemovesDirectory() { - $extDirPath = PATH_site . '/typo3temp/var/tests/' . $this->getUniqueId('test-extensions-'); + $extDirPath = Environment::getVarPath() . '/tests/' . $this->getUniqueId('test-extensions-'); @mkdir($extDirPath); $fileHandlerMock = $this->getAccessibleMock(FileHandlingUtility::class, ['dummy']); $fileHandlerMock->_call('removeDirectory', $extDirPath); @@ -179,8 +179,8 @@ class FileHandlingUtilityTest extends UnitTestCase */ public function removeDirectoryRemovesSymlink() { - $absoluteSymlinkPath = PATH_site . 'typo3temp/var/tests/' . $this->getUniqueId('test_symlink_'); - $absoluteFilePath = PATH_site . 'typo3temp/var/tests/' . $this->getUniqueId('test_file_'); + $absoluteSymlinkPath = Environment::getVarPath() . '/tests/' . $this->getUniqueId('test_symlink_'); + $absoluteFilePath = Environment::getVarPath() . '/tests/' . $this->getUniqueId('test_file_'); touch($absoluteFilePath); $this->testFilesToDelete[] = $absoluteFilePath; symlink($absoluteFilePath, $absoluteSymlinkPath); @@ -194,8 +194,8 @@ class FileHandlingUtilityTest extends UnitTestCase */ public function removeDirectoryDoesNotRemoveContentOfSymlinkedTargetDirectory() { - $absoluteSymlinkPath = PATH_site . 'typo3temp/var/tests/' . $this->getUniqueId('test_symlink_'); - $absoluteDirectoryPath = PATH_site . 'typo3temp/var/tests/' . $this->getUniqueId('test_dir_') . '/'; + $absoluteSymlinkPath = Environment::getVarPath() . '/tests/' . $this->getUniqueId('test_symlink_'); + $absoluteDirectoryPath = Environment::getVarPath() . '/tests/' . $this->getUniqueId('test_dir_') . '/'; $relativeFilePath = $this->getUniqueId('test_file_'); mkdir($absoluteDirectoryPath); diff --git a/typo3/sysext/extensionmanager/Tests/Unit/Utility/InstallUtilityTest.php b/typo3/sysext/extensionmanager/Tests/Unit/Utility/InstallUtilityTest.php index 0aa6278f4c9ce36b2009c40b71dda71961adde19..2c5fab9063bd97402d6e016b6f3cdf494497ce8e 100644 --- a/typo3/sysext/extensionmanager/Tests/Unit/Utility/InstallUtilityTest.php +++ b/typo3/sysext/extensionmanager/Tests/Unit/Utility/InstallUtilityTest.php @@ -16,6 +16,7 @@ namespace TYPO3\CMS\Extensionmanager\Tests\Unit\Utility; */ use TYPO3\CMS\Core\Cache\CacheManager; +use TYPO3\CMS\Core\Core\Environment; use TYPO3\CMS\Core\Registry; use TYPO3\CMS\Core\Utility\GeneralUtility; use TYPO3\CMS\Extensionmanager\Utility\DependencyUtility; @@ -101,7 +102,7 @@ class InstallUtilityTest extends UnitTestCase protected function tearDown() { foreach ($this->fakedExtensions as $fakeExtkey => $fakeExtension) { - $this->testFilesToDelete[] = PATH_site . 'typo3temp/var/tests/' . $fakeExtkey; + $this->testFilesToDelete[] = Environment::getVarPath() . '/tests/' . $fakeExtkey; } parent::tearDown(); } @@ -115,7 +116,7 @@ class InstallUtilityTest extends UnitTestCase protected function createFakeExtension(): string { $extKey = strtolower($this->getUniqueId('testing')); - $absExtPath = PATH_site . 'typo3temp/var/tests/' . $extKey; + $absExtPath = Environment::getVarPath() . '/tests/' . $extKey; $relPath = 'typo3temp/var/tests/' . $extKey . '/'; GeneralUtility::mkdir($absExtPath); $this->fakedExtensions[$extKey] = [ @@ -226,7 +227,7 @@ class InstallUtilityTest extends UnitTestCase public function processDatabaseUpdatesCallsUpdateDbWithExtTablesSql() { $extKey = $this->createFakeExtension(); - $extPath = PATH_site . 'typo3temp/var/tests/' . $extKey . '/'; + $extPath = Environment::getVarPath() . '/tests/' . $extKey . '/'; $extTablesFile = $extPath . 'ext_tables.sql'; $fileContent = 'DUMMY TEXT TO COMPARE'; file_put_contents($extTablesFile, $fileContent); @@ -287,7 +288,7 @@ class InstallUtilityTest extends UnitTestCase public function processDatabaseUpdatesCallsImportFile($fileName) { $extKey = $this->createFakeExtension(); - $absPath = PATH_site . $this->fakedExtensions[$extKey]['siteRelPath']; + $absPath = Environment::getPublicPath() . '/' . $this->fakedExtensions[$extKey]['siteRelPath']; GeneralUtility::mkdir($absPath . '/Initialisation'); file_put_contents($absPath . '/Initialisation/' . $fileName, 'DUMMY'); $installMock = $this->getAccessibleMock( @@ -342,7 +343,7 @@ class InstallUtilityTest extends UnitTestCase public function importT3DFileDoesNotImportFileIfAlreadyImported($fileName, $registryNameReturnsFalse, $registryNameReturnsTrue) { $extKey = $this->createFakeExtension(); - $absPath = PATH_site . $this->fakedExtensions[$extKey]['siteRelPath']; + $absPath = Environment::getPublicPath() . '/' . $this->fakedExtensions[$extKey]['siteRelPath']; GeneralUtility::mkdir($absPath . 'Initialisation'); file_put_contents($absPath . 'Initialisation/' . $fileName, 'DUMMY'); $registryMock = $this->getMockBuilder(Registry::class)