Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commitf07cee8

Browse files
committed
[Filesystem] rename Filesystem::mirror() option copy_on_windows to follow_symlinks
1 parent047029b commitf07cee8

File tree

4 files changed

+38
-4
lines changed

4 files changed

+38
-4
lines changed

‎UPGRADE-6.3.md

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
UPGRADE FROM 6.2 to 6.3
2+
=======================
3+
4+
Filesystem
5+
----
6+
7+
* Deprecate calling`Filesystem::mirror()` with option`copy_on_windows`, use option`follow_symlinks` instead.

‎src/Symfony/Component/Filesystem/CHANGELOG.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,11 @@
11
CHANGELOG
22
=========
33

4+
6.3
5+
---
6+
7+
* Deprecate calling`Filesystem::mirror()` with option`copy_on_windows`, use option`follow_symlinks` instead.
8+
49
5.4
510
---
611

‎src/Symfony/Component/Filesystem/Filesystem.php

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -505,13 +505,17 @@ public function makePathRelative(string $endPath, string $startPath): string
505505
* @param array $options An array of boolean options
506506
* Valid options are:
507507
* - $options['override'] If true, target files newer than origin files are overwritten (see copy(), defaults to false)
508-
* - $options['copy_on_windows'] Whether to copy files instead of links on Windows (see symlink(), defaults to false)
508+
* - $options['copy_on_windows'] (deprecated) Whether to copy files instead of links on Windows (see symlink(), defaults to false)
509+
* - $options['follow_symlinks'] Whether to copy files instead of links, where using symlinks in not working: windows, different drive, docker context not supporting symlinks (see symlink(), defaults to false)
509510
* - $options['delete'] Whether to delete files that are not in the source directory (defaults to false)
510511
*
511512
* @throws IOException When file type is unknown
512513
*/
513514
publicfunctionmirror(string$originDir,string$targetDir,\Traversable$iterator =null,array$options = [])
514515
{
516+
if (isset($options['copy_on_windows'])) {
517+
trigger_deprecation('symfony/filesystem','6.3','Calling "%s()" with option "copy_on_windows" is deprecated, use "follow_symlinks" option instead.',__METHOD__);
518+
}
515519
$targetDir =rtrim($targetDir,'/\\');
516520
$originDir =rtrim($originDir,'/\\');
517521
$originDirLen =\strlen($originDir);
@@ -536,10 +540,10 @@ public function mirror(string $originDir, string $targetDir, \Traversable $itera
536540
}
537541
}
538542

539-
$copyOnWindows =$options['copy_on_windows'] ??false;
543+
$followSymlinks =($options['follow_symlinks'] ??false) || ($options['copy_on_windows'] ??false);
540544

541545
if (null ===$iterator) {
542-
$flags =$copyOnWindows ? \FilesystemIterator::SKIP_DOTS | \FilesystemIterator::FOLLOW_SYMLINKS : \FilesystemIterator::SKIP_DOTS;
546+
$flags =$followSymlinks ? \FilesystemIterator::SKIP_DOTS | \FilesystemIterator::FOLLOW_SYMLINKS : \FilesystemIterator::SKIP_DOTS;
543547
$iterator =new \RecursiveIteratorIterator(new \RecursiveDirectoryIterator($originDir,$flags), \RecursiveIteratorIterator::SELF_FIRST);
544548
}
545549

@@ -554,7 +558,7 @@ public function mirror(string $originDir, string $targetDir, \Traversable $itera
554558
$target =$targetDir.substr($file->getPathname(),$originDirLen);
555559
$filesCreatedWhileMirroring[$target] =true;
556560

557-
if (!$copyOnWindows &&is_link($file)) {
561+
if (!$followSymlinks &&is_link($file)) {
558562
$this->symlink($file->getLinkTarget(),$target);
559563
}elseif (is_dir($file)) {
560564
$this->mkdir($target);

‎src/Symfony/Component/Filesystem/Tests/FilesystemTest.php

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1282,6 +1282,24 @@ public function testMirrorCopiesLinks()
12821282
$this->assertTrue(is_link($targetPath.\DIRECTORY_SEPARATOR.'link1'));
12831283
}
12841284

1285+
publicfunctiontestMirrorCopiesLinksByFollowingSymlinks()
1286+
{
1287+
$this->markAsSkippedIfSymlinkIsMissing();
1288+
1289+
$sourcePath =$this->workspace.\DIRECTORY_SEPARATOR.'source'.\DIRECTORY_SEPARATOR;
1290+
1291+
mkdir($sourcePath);
1292+
file_put_contents($sourcePath.'file1','FILE1');
1293+
symlink($sourcePath.'file1',$sourcePath.'link1');
1294+
1295+
$targetPath =$this->workspace.\DIRECTORY_SEPARATOR.'target'.\DIRECTORY_SEPARATOR;
1296+
1297+
$this->filesystem->mirror($sourcePath,$targetPath,null, ['follow_symlinks' =>true]);
1298+
1299+
$this->assertDirectoryExists($targetPath);
1300+
$this->assertFalse(is_link($targetPath.\DIRECTORY_SEPARATOR.'link1'));
1301+
}
1302+
12851303
publicfunctiontestMirrorCopiesLinkedDirectoryContents()
12861304
{
12871305
$this->markAsSkippedIfSymlinkIsMissing(true);

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp