Skip to content

Commit 7750284

Browse files
Merge branch '4.3' into 4.4
* 4.3: (34 commits) [PhpunitBridge] Read environment variable from superglobals [Bridge/PhpUnit] Fix PHP5.5 compat [PhpUnitBridge] More accurate grouping fixed CS Extract unrecoverable exception to interface [FrameworkBundle] Fix calling Client::getProfile() before sending a request Fix type error [Security/Core] require libsodium >= 1.0.14 [Workflow] re-add workflow.definition tag to workflow services [Security/Core] Don't use ParagonIE_Sodium_Compat revert #30525 due to performance penalty collect called listeners information only once [Lock] fix missing inherit docs in RedisStore [Messenger] fix retrying handlers using DoctrineTransactionMiddleware [Mailgun Mailer] fixed issue when using html body [HttpClient] fix timing measurements with NativeHttpClient [HttpClient] fix dealing with 1xx informational responses add test to avoid regressions fix mirroring directory into parent directory fix typos ...
2 parents 762f6dc + b9896d0 commit 7750284

File tree

2 files changed

+19
-2
lines changed

2 files changed

+19
-2
lines changed

Filesystem.php

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -569,14 +569,15 @@ public function mirror($originDir, $targetDir, \Traversable $iterator = null, $o
569569
}
570570

571571
$this->mkdir($targetDir);
572-
$targetDirInfo = new \SplFileInfo($targetDir);
572+
$filesCreatedWhileMirroring = [];
573573

574574
foreach ($iterator as $file) {
575-
if ($file->getPathname() === $targetDir || $file->getRealPath() === $targetDir || 0 === strpos($file->getRealPath(), $targetDirInfo->getRealPath())) {
575+
if ($file->getPathname() === $targetDir || $file->getRealPath() === $targetDir || isset($filesCreatedWhileMirroring[$file->getRealPath()])) {
576576
continue;
577577
}
578578

579579
$target = $targetDir.substr($file->getPathname(), $originDirLen);
580+
$filesCreatedWhileMirroring[$target] = true;
580581

581582
if (!$copyOnWindows && is_link($file)) {
582583
$this->symlink($file->getLinkTarget(), $target);

Tests/FilesystemTest.php

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1362,6 +1362,22 @@ public function testMirrorAvoidCopyingTargetDirectoryIfInSourceDirectory()
13621362
$this->assertFalse($this->filesystem->exists($targetPath.'target'));
13631363
}
13641364

1365+
public function testMirrorFromSubdirectoryInToParentDirectory()
1366+
{
1367+
$targetPath = $this->workspace.\DIRECTORY_SEPARATOR.'foo'.\DIRECTORY_SEPARATOR;
1368+
$sourcePath = $targetPath.'bar'.\DIRECTORY_SEPARATOR;
1369+
$file1 = $sourcePath.'file1';
1370+
$file2 = $sourcePath.'file2';
1371+
1372+
$this->filesystem->mkdir($sourcePath);
1373+
file_put_contents($file1, 'FILE1');
1374+
file_put_contents($file2, 'FILE2');
1375+
1376+
$this->filesystem->mirror($sourcePath, $targetPath);
1377+
1378+
$this->assertFileEquals($file1, $targetPath.'file1');
1379+
}
1380+
13651381
/**
13661382
* @dataProvider providePathsForIsAbsolutePath
13671383
*/

0 commit comments

Comments
 (0)