[BUGFIX] GeneralUtility::copyDirectory() should mkdir_deep() destination dir 61/55361/2
authorChristian Kuhn <lolli@schwarzbu.ch>
Sun, 14 Jan 2018 17:10:38 +0000 (18:10 +0100)
committerChristian Kuhn <lolli@schwarzbu.ch>
Sun, 14 Jan 2018 18:56:59 +0000 (19:56 +0100)
If path to the destination directory does not exist yet,
copyDirectory() does not copy anything. Use mkdir_deep() for directories.

As example, have directory 'typo3temp' and call copyDirectory()
with a destination 'typo3temp/foo/bar', where 'foo' does not
exist, yet. Without patch, this operation fails.

Change-Id: Id8eb5d6cd30c288ca073e98d35a3025c8489c182
Resolves: #83564
Releases: master, 8.7
Reviewed-on: https://review.typo3.org/55361
Tested-by: TYPO3com <no-reply@typo3.com>
Reviewed-by: Christian Kuhn <lolli@schwarzbu.ch>
Tested-by: Christian Kuhn <lolli@schwarzbu.ch>
typo3/sysext/core/Classes/Utility/GeneralUtility.php
typo3/sysext/core/Tests/Unit/Utility/GeneralUtilityTest.php

index 918d474..23dddae 100644 (file)
@@ -3382,6 +3382,7 @@ class GeneralUtility
             $destination = PATH_site . $destination;
         }
         if (static::isAllowedAbsPath($source) && static::isAllowedAbsPath($destination)) {
+            static::mkdir_deep($destination);
             $iterator = new \RecursiveIteratorIterator(
                 new \RecursiveDirectoryIterator($source, \RecursiveDirectoryIterator::SKIP_DOTS),
                 \RecursiveIteratorIterator::SELF_FIRST
index af6d0e8..73bdaf1 100644 (file)
@@ -4433,7 +4433,6 @@ class GeneralUtilityTest extends \TYPO3\TestingFramework\Core\Unit\UnitTestCase
         $targetDirectory = 'typo3temp/var/tests/' . $this->getUniqueId('test_') . '/';
         $absoluteTargetDirectory = PATH_site . $targetDirectory;
         $this->testFilesToDelete[] = $absoluteTargetDirectory;
-        GeneralUtility::mkdir($absoluteTargetDirectory);
 
         GeneralUtility::writeFileToTypo3tempDir($absoluteSourceDirectory . 'file', '42');
         GeneralUtility::mkdir($absoluteSourceDirectory . 'foo');
@@ -4458,7 +4457,6 @@ class GeneralUtilityTest extends \TYPO3\TestingFramework\Core\Unit\UnitTestCase
         $targetDirectory = 'typo3temp/var/tests/' . $this->getUniqueId('test_') . '/';
         $absoluteTargetDirectory = PATH_site . $targetDirectory;
         $this->testFilesToDelete[] = $absoluteTargetDirectory;
-        GeneralUtility::mkdir($absoluteTargetDirectory);
 
         GeneralUtility::writeFileToTypo3tempDir($absoluteSourceDirectory . 'file', '42');
         GeneralUtility::mkdir($absoluteSourceDirectory . 'foo');