diff --git a/typo3/sysext/core/Classes/DataHandling/DataHandler.php b/typo3/sysext/core/Classes/DataHandling/DataHandler.php index 46e46348d1b2c0abfd763e934f85c1675ed34c68..45135366cc1f2e98c2ec610fafaff3eab23faa9b 100644 --- a/typo3/sysext/core/Classes/DataHandling/DataHandler.php +++ b/typo3/sysext/core/Classes/DataHandling/DataHandler.php @@ -2315,7 +2315,7 @@ class DataHandler } elseif (@is_file($theFile)) { $dest = dirname(PATH_site . $this->alternativeFilePath[$theFile]); if (!@is_dir($dest)) { - GeneralUtility::mkdir_deep(PATH_site, dirname($this->alternativeFilePath[$theFile]) . '/'); + GeneralUtility::mkdir_deep($dest); } // Init: $maxSize = (int)$tcaFieldConf['max_size']; diff --git a/typo3/sysext/core/Classes/Resource/Driver/LocalDriver.php b/typo3/sysext/core/Classes/Resource/Driver/LocalDriver.php index 56b0654d8dd0af18b2c13e55f89bcbb5115e362b..1a8c29d73eeca00656d749cf5e96323fd2830590 100644 --- a/typo3/sysext/core/Classes/Resource/Driver/LocalDriver.php +++ b/typo3/sysext/core/Classes/Resource/Driver/LocalDriver.php @@ -231,7 +231,7 @@ class LocalDriver extends AbstractHierarchicalFilesystemDriver $parts = array_map([$this, 'sanitizeFileName'], $parts); $newFolderName = implode('/', $parts); $newIdentifier = $parentFolderIdentifier . $newFolderName . '/'; - GeneralUtility::mkdir_deep($this->getAbsolutePath($parentFolderIdentifier) . '/', $newFolderName); + GeneralUtility::mkdir_deep($this->getAbsolutePath($parentFolderIdentifier) . '/' . $newFolderName); } return $newIdentifier; } diff --git a/typo3/sysext/core/Classes/Utility/GeneralUtility.php b/typo3/sysext/core/Classes/Utility/GeneralUtility.php index 8f4fba0549957fa9168d851becd58c991f6be4db..716710f4efd9d153b6468c7a4d65f3c84f8fb21d 100644 --- a/typo3/sysext/core/Classes/Utility/GeneralUtility.php +++ b/typo3/sysext/core/Classes/Utility/GeneralUtility.php @@ -1996,7 +1996,7 @@ class GeneralUtility if (preg_match('#^(?:[[:alnum:]_]+/)+$#', $subdir)) { $dirName .= $subdir; if (!@is_dir($dirName)) { - static::mkdir_deep(PATH_site . 'typo3temp/', $subdir); + static::mkdir_deep(PATH_site . 'typo3temp/' . $subdir); } } else { return 'Subdir, "' . $subdir . '", was NOT on the form "[[:alnum:]_]/+"'; @@ -2053,7 +2053,11 @@ class GeneralUtility throw new \InvalidArgumentException('The specified directory is of type "' . gettype($deepDirectory) . '" but a string is expected.', 1303662956); } // Ensure there is only one slash - $fullPath = rtrim($directory, '/') . '/' . ltrim($deepDirectory, '/'); + $fullPath = rtrim($directory, '/') . '/'; + if ($deepDirectory !== '') { + trigger_error('Second argument $deepDirectory of GeneralUtility::mkdir_deep() will be removed in TYPO3 v10.0, use a combined string as first argument instead.', E_USER_DEPRECATED); + $fullPath .= ltrim($deepDirectory, '/'); + } if ($fullPath !== '/' && !is_dir($fullPath)) { $firstCreatedPath = static::createDirectoryPath($fullPath); if ($firstCreatedPath !== '') { diff --git a/typo3/sysext/core/Documentation/Changelog/master/Deprecation-82702-SecondArgumentOfGeneralUtilitymkdir_deep.rst b/typo3/sysext/core/Documentation/Changelog/master/Deprecation-82702-SecondArgumentOfGeneralUtilitymkdir_deep.rst new file mode 100644 index 0000000000000000000000000000000000000000..ace3063447a10e5e3efb776af7d1ea760efc6734 --- /dev/null +++ b/typo3/sysext/core/Documentation/Changelog/master/Deprecation-82702-SecondArgumentOfGeneralUtilitymkdir_deep.rst @@ -0,0 +1,35 @@ +.. include:: ../../Includes.txt + +===================================================================== +Deprecation: #82702 - Second argument of GeneralUtility::mkdir_deep() +===================================================================== + +See :issue:`82702` + +Description +=========== + +The second option of :php:`TYPO3\CMS\Core\Utility\GeneralUtility::mkdir_deep()` has been marked +as deprecated. + + +Impact +====== + +Calling this method with a second argument which is not empty, will trigger a deprecation entry. + + +Affected Installations +====================== + +Any installation with a third-party extension calling this method with two arguments. + + +Migration +========= + +Instead of calling `GeneralUtility::mkdir_deep(PATH_site . 'typo3temp/', 'myfolder');` the simple +syntax GeneralUtility::mkdir_deep(PATH_site . 'typo3temp/myfolder'); can be used directly, also +in TYPO3 v8 and before already. + +.. index:: PHP-API, FullyScanned \ No newline at end of file diff --git a/typo3/sysext/core/Tests/Unit/Resource/Driver/LocalDriverTest.php b/typo3/sysext/core/Tests/Unit/Resource/Driver/LocalDriverTest.php index f671d31883793657f7a536c0dc23a380be074f1f..57b9f4bef3a401ab8faaa8a8c76962dc6de4f140 100644 --- a/typo3/sysext/core/Tests/Unit/Resource/Driver/LocalDriverTest.php +++ b/typo3/sysext/core/Tests/Unit/Resource/Driver/LocalDriverTest.php @@ -1429,8 +1429,8 @@ class LocalDriverTest extends \TYPO3\CMS\Core\Tests\Unit\Resource\BaseTestCase public function copyFolderWithinStorageCopiesSingleSubFolderToNewFolderName() { list($basePath, $subject) = $this->prepareRealTestEnvironment(); - GeneralUtility::mkdir_deep($basePath, '/sourceFolder/subFolder'); - GeneralUtility::mkdir_deep($basePath, '/targetFolder'); + GeneralUtility::mkdir_deep($basePath . '/sourceFolder/subFolder'); + GeneralUtility::mkdir_deep($basePath . '/targetFolder'); $subject->copyFolderWithinStorage('/sourceFolder/', '/targetFolder/', 'newFolderName'); $this->assertTrue(is_dir($basePath . '/targetFolder/newFolderName/subFolder')); @@ -1442,8 +1442,8 @@ class LocalDriverTest extends \TYPO3\CMS\Core\Tests\Unit\Resource\BaseTestCase public function copyFolderWithinStorageCopiesFileInSingleSubFolderToNewFolderName() { list($basePath, $subject) = $this->prepareRealTestEnvironment(); - GeneralUtility::mkdir_deep($basePath, '/sourceFolder/subFolder'); - GeneralUtility::mkdir_deep($basePath, '/targetFolder'); + GeneralUtility::mkdir_deep($basePath . '/sourceFolder/subFolder'); + GeneralUtility::mkdir_deep($basePath . '/targetFolder'); file_put_contents($basePath . '/sourceFolder/subFolder/file', $this->getUniqueId()); GeneralUtility::fixPermissions($basePath . '/sourceFolder/subFolder/file'); diff --git a/typo3/sysext/core/Tests/Unit/Utility/GeneralUtilityTest.php b/typo3/sysext/core/Tests/Unit/Utility/GeneralUtilityTest.php index 9ca32d69b8cffe4f7b066e41faa7764ab4b364c0..837ce73526144eaec0ed0ed93fc5982c4f818479 100644 --- a/typo3/sysext/core/Tests/Unit/Utility/GeneralUtilityTest.php +++ b/typo3/sysext/core/Tests/Unit/Utility/GeneralUtilityTest.php @@ -2907,7 +2907,7 @@ class GeneralUtilityTest extends \TYPO3\TestingFramework\Core\Unit\UnitTestCase // Load fixture files and folders from disk FileStreamWrapper::init(PATH_site); FileStreamWrapper::registerOverlayPath('fileadmin', 'vfs://root/fileadmin', true); - GeneralUtility::mkdir_deep(PATH_site, $directoryToCreate); + GeneralUtility::mkdir_deep(PATH_site . $directoryToCreate); $this->assertTrue(is_dir(PATH_site . $directoryToCreate)); FileStreamWrapper::destroy(); } @@ -2923,7 +2923,7 @@ class GeneralUtilityTest extends \TYPO3\TestingFramework\Core\Unit\UnitTestCase $directory = $this->getUniqueId('mkdirdeeptest_'); $oldUmask = umask(19); $GLOBALS['TYPO3_CONF_VARS']['SYS']['folderCreateMask'] = '0777'; - GeneralUtility::mkdir_deep(PATH_site . 'typo3temp/var/tests/', $directory); + GeneralUtility::mkdir_deep(PATH_site . 'typo3temp/var/tests/' . $directory); $this->testFilesToDelete[] = PATH_site . 'typo3temp/var/tests/' . $directory; clearstatcache(); umask($oldUmask); @@ -2942,7 +2942,7 @@ class GeneralUtilityTest extends \TYPO3\TestingFramework\Core\Unit\UnitTestCase $subDirectory = $directory . '/bar'; $GLOBALS['TYPO3_CONF_VARS']['SYS']['folderCreateMask'] = '0777'; $oldUmask = umask(19); - GeneralUtility::mkdir_deep(PATH_site . 'typo3temp/var/tests/', $subDirectory); + GeneralUtility::mkdir_deep(PATH_site . 'typo3temp/var/tests/' . $subDirectory); $this->testFilesToDelete[] = PATH_site . 'typo3temp/var/tests/' . $directory; clearstatcache(); umask($oldUmask); @@ -2963,7 +2963,7 @@ class GeneralUtilityTest extends \TYPO3\TestingFramework\Core\Unit\UnitTestCase @mkdir(($baseDirectory . $existingDirectory)); $this->testFilesToDelete[] = $baseDirectory . $existingDirectory; chmod($baseDirectory . $existingDirectory, 482); - GeneralUtility::mkdir_deep($baseDirectory, $existingDirectory . $newSubDirectory); + GeneralUtility::mkdir_deep($baseDirectory . $existingDirectory . $newSubDirectory); $this->assertEquals('0742', substr(decoct(fileperms($baseDirectory . $existingDirectory)), 2)); } @@ -2976,7 +2976,7 @@ class GeneralUtilityTest extends \TYPO3\TestingFramework\Core\Unit\UnitTestCase if ($swapGroup !== false) { $GLOBALS['TYPO3_CONF_VARS']['SYS']['createGroup'] = $swapGroup; $directory = $this->getUniqueId('mkdirdeeptest_'); - GeneralUtility::mkdir_deep(PATH_site . 'typo3temp/var/tests/', $directory); + GeneralUtility::mkdir_deep(PATH_site . 'typo3temp/var/tests/' . $directory); $this->testFilesToDelete[] = PATH_site . 'typo3temp/var/tests/' . $directory; clearstatcache(); $resultDirectoryGroup = filegroup(PATH_site . 'typo3temp/var/tests/' . $directory); @@ -2994,7 +2994,7 @@ class GeneralUtilityTest extends \TYPO3\TestingFramework\Core\Unit\UnitTestCase $GLOBALS['TYPO3_CONF_VARS']['SYS']['createGroup'] = $swapGroup; $directory = $this->getUniqueId('mkdirdeeptest_'); $subDirectory = $directory . '/bar'; - GeneralUtility::mkdir_deep(PATH_site . 'typo3temp/var/tests/', $subDirectory); + GeneralUtility::mkdir_deep(PATH_site . 'typo3temp/var/tests/' . $subDirectory); $this->testFilesToDelete[] = PATH_site . 'typo3temp/var/tests/' . $directory; clearstatcache(); $resultDirectoryGroup = filegroup(PATH_site . 'typo3temp/var/tests/' . $directory); @@ -3012,7 +3012,7 @@ class GeneralUtilityTest extends \TYPO3\TestingFramework\Core\Unit\UnitTestCase $GLOBALS['TYPO3_CONF_VARS']['SYS']['createGroup'] = $swapGroup; $directory = $this->getUniqueId('mkdirdeeptest_'); $subDirectory = $directory . '/bar'; - GeneralUtility::mkdir_deep(PATH_site . 'typo3temp/var/tests/', $subDirectory); + GeneralUtility::mkdir_deep(PATH_site . 'typo3temp/var/tests/' . $subDirectory); $this->testFilesToDelete[] = PATH_site . 'typo3temp/var/tests/' . $directory; clearstatcache(); $resultDirectoryGroup = filegroup(PATH_site . 'typo3temp/var/tests/' . $directory); @@ -3031,7 +3031,7 @@ class GeneralUtilityTest extends \TYPO3\TestingFramework\Core\Unit\UnitTestCase vfsStreamWrapper::register(); $baseDirectory = $this->getUniqueId('test_'); vfsStreamWrapper::setRoot(new vfsStreamDirectory($baseDirectory)); - GeneralUtility::mkdir_deep('vfs://' . $baseDirectory . '/', 'sub'); + GeneralUtility::mkdir_deep('vfs://' . $baseDirectory . '/sub'); $this->assertTrue(is_dir('vfs://' . $baseDirectory . '/sub')); } diff --git a/typo3/sysext/documentation/Classes/Service/DocumentationService.php b/typo3/sysext/documentation/Classes/Service/DocumentationService.php index 30c9db4c550cfbcf23bb5a2a0a82e84b470ef413..0756b9e72d0a1c636d02633cabc8d3a526d839b4 100644 --- a/typo3/sysext/documentation/Classes/Service/DocumentationService.php +++ b/typo3/sysext/documentation/Classes/Service/DocumentationService.php @@ -298,7 +298,7 @@ class DocumentationService $fileName = array_pop($zipEntryPathSegments); // It is a folder, because the last segment is empty, let's create it if (empty($fileName)) { - GeneralUtility::mkdir_deep($path, implode('/', $zipEntryPathSegments)); + GeneralUtility::mkdir_deep($path . implode('/', $zipEntryPathSegments)); } else { $absoluteTargetPath = GeneralUtility::getFileAbsFileName($path . implode('/', $zipEntryPathSegments) . '/' . $fileName); if (trim($absoluteTargetPath) !== '') { diff --git a/typo3/sysext/install/Configuration/ExtensionScanner/Php/MethodArgumentDroppedMatcher.php b/typo3/sysext/install/Configuration/ExtensionScanner/Php/MethodArgumentDroppedMatcher.php index 3a713f4fee0432c1f6ccd94412f595905b539973..c6b33081215539dfa2fdcee3d8d178ba3072e81c 100644 --- a/typo3/sysext/install/Configuration/ExtensionScanner/Php/MethodArgumentDroppedMatcher.php +++ b/typo3/sysext/install/Configuration/ExtensionScanner/Php/MethodArgumentDroppedMatcher.php @@ -123,4 +123,10 @@ return [ 'Breaking-82629-TceDbOptionsPrErrAndUPTRemoved.rst', ], ], + 'TYPO3\CMS\Core\Utility\GeneralUtility->mkdir_deep' => [ + 'maximumNumberOfArguments' => 1, + 'restFiles' => [ + 'Deprecation-82702-SecondArgumentOfGeneralUtilitymkdir_deep.rst', + ], + ], ]; diff --git a/typo3/sysext/lang/Classes/Service/TerService.php b/typo3/sysext/lang/Classes/Service/TerService.php index 2ac9757c499dcedb0ee1d7d1434e3fdbbbc20d80..c452cfae1b84b48344c25ee6ff8067b508ae6659 100644 --- a/typo3/sysext/lang/Classes/Service/TerService.php +++ b/typo3/sysext/lang/Classes/Service/TerService.php @@ -143,7 +143,7 @@ class TerService extends TerUtility implements SingletonInterface throw new LanguageException('Given path is invalid.', 1352565336); } if (!is_dir($absoluteLanguagePath)) { - GeneralUtility::mkdir_deep(PATH_typo3conf, $relativeLanguagePath); + GeneralUtility::mkdir_deep($absoluteLanguagePath); } GeneralUtility::writeFileToTypo3tempDir($absolutePathToZipFile, $l10n[0]); if (is_dir($absoluteExtensionLanguagePath)) { @@ -220,7 +220,7 @@ class TerService extends TerUtility implements SingletonInterface $fileName = array_pop($zipEntryPathSegments); // It is a folder, because the last segment is empty, let's create it if (empty($fileName)) { - GeneralUtility::mkdir_deep($path, implode('/', $zipEntryPathSegments)); + GeneralUtility::mkdir_deep($path . implode('/', $zipEntryPathSegments)); } else { $absoluteTargetPath = GeneralUtility::getFileAbsFileName($path . implode('/', $zipEntryPathSegments) . '/' . $fileName); if (trim($absoluteTargetPath) !== '') {