[BUGFIX] GeneralUtility::copyDirectory() should mkdir_deep() destination dir 60/55360/3
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:37:28 +0000 (19:37 +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/55360
Tested-by: TYPO3com <no-reply@typo3.com>
Reviewed-by: Benjamin Kott <benjamin.kott@outlook.com>
Tested-by: Benjamin Kott <benjamin.kott@outlook.com>
Reviewed-by: Anja Leichsenring <aleichsenring@ab-softlab.de>
Tested-by: Anja Leichsenring <aleichsenring@ab-softlab.de>
Reviewed-by: Riccardo De Contardi <erredeco@gmail.com>
Reviewed-by: Wouter Wolters <typo3@wouterwolters.nl>
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 4c4dbb1..37900f4 100644 (file)
@@ -3121,6 +3121,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 660faa9..0b219da 100644 (file)
@@ -4203,7 +4203,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');
@@ -4228,7 +4227,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');