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

Commitbe1d2e2

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

File tree

4 files changed

+36
-4
lines changed

4 files changed

+36
-4
lines changed

‎UPGRADE-6.3.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,11 @@ DependencyInjection
77
* Deprecate`PhpDumper` options`inline_factories_parameter` and`inline_class_loader_parameter`, use`inline_factories` and`inline_class_loader` instead
88
* Deprecate undefined and numeric keys with`service_locator` config, use string aliases instead
99

10+
Filesystem
11+
----------
12+
13+
* Deprecate calling`Filesystem::mirror()` with option`copy_on_windows`, use option`follow_symlinks` instead.
14+
1015
FrameworkBundle
1116
---------------
1217

‎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
@@ -503,13 +503,17 @@ public function makePathRelative(string $endPath, string $startPath): string
503503
* @param array $options An array of boolean options
504504
* Valid options are:
505505
* - $options['override'] If true, target files newer than origin files are overwritten (see copy(), defaults to false)
506-
* - $options['copy_on_windows'] Whether to copy files instead of links on Windows (see symlink(), defaults to false)
506+
* - $options['copy_on_windows'] (deprecated) Whether to copy files instead of links on Windows (see symlink(), defaults to false)
507+
* - $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)
507508
* - $options['delete'] Whether to delete files that are not in the source directory (defaults to false)
508509
*
509510
* @throws IOException When file type is unknown
510511
*/
511512
publicfunctionmirror(string$originDir,string$targetDir,\Traversable$iterator =null,array$options = [])
512513
{
514+
if (isset($options['copy_on_windows'])) {
515+
trigger_deprecation('symfony/filesystem','6.3','Calling "%s()" with option "copy_on_windows" is deprecated, use "follow_symlinks" option instead.',__METHOD__);
516+
}
513517
$targetDir =rtrim($targetDir,'/\\');
514518
$originDir =rtrim($originDir,'/\\');
515519
$originDirLen =\strlen($originDir);
@@ -534,10 +538,10 @@ public function mirror(string $originDir, string $targetDir, \Traversable $itera
534538
}
535539
}
536540

537-
$copyOnWindows =$options['copy_on_windows'] ??false;
541+
$followSymlinks =($options['follow_symlinks'] ??false) || ($options['copy_on_windows'] ??false);
538542

539543
if (null ===$iterator) {
540-
$flags =$copyOnWindows ? \FilesystemIterator::SKIP_DOTS | \FilesystemIterator::FOLLOW_SYMLINKS : \FilesystemIterator::SKIP_DOTS;
544+
$flags =$followSymlinks ? \FilesystemIterator::SKIP_DOTS | \FilesystemIterator::FOLLOW_SYMLINKS : \FilesystemIterator::SKIP_DOTS;
541545
$iterator =new \RecursiveIteratorIterator(new \RecursiveDirectoryIterator($originDir,$flags), \RecursiveIteratorIterator::SELF_FIRST);
542546
}
543547

@@ -552,7 +556,7 @@ public function mirror(string $originDir, string $targetDir, \Traversable $itera
552556
$target =$targetDir.substr($file->getPathname(),$originDirLen);
553557
$filesCreatedWhileMirroring[$target] =true;
554558

555-
if (!$copyOnWindows &&is_link($file)) {
559+
if (!$followSymlinks &&is_link($file)) {
556560
$this->symlink($file->getLinkTarget(),$target);
557561
}elseif (is_dir($file)) {
558562
$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