File tree Expand file tree Collapse file tree 2 files changed +34
-2
lines changed
dev/tests/integration/testsuite/Magento/Framework/Filesystem/Driver
lib/internal/Magento/Framework/Filesystem/Driver Expand file tree Collapse file tree 2 files changed +34
-2
lines changed Original file line number Diff line number Diff line change @@ -64,6 +64,32 @@ protected function tearDown(): void
64
64
$ this ->removeGeneratedDirectory ();
65
65
}
66
66
67
+ /**
68
+ * Tests read directory with symlynked folders.
69
+ *
70
+ * @return void
71
+ */
72
+ public function testReadDirectoryRecursivelyWithSymlinkedFolders (): void
73
+ {
74
+ $ sourceDirectory = $ this ->generatedPath . '/source ' ;
75
+ $ destinationDirectory = $ this ->generatedPath . '/destination ' ;
76
+
77
+ $ this ->driver ->createDirectory ($ sourceDirectory );
78
+ $ this ->driver ->createDirectory ($ sourceDirectory . '/directory1 ' );
79
+ $ this ->driver ->createDirectory ($ destinationDirectory );
80
+
81
+ $ linkName = $ destinationDirectory . '/link ' ;
82
+ $ this ->driver ->symlink ($ sourceDirectory , $ linkName );
83
+
84
+ $ paths = [
85
+ $ destinationDirectory . '/link ' . '/directory1 ' ,
86
+ $ destinationDirectory . '/link '
87
+
88
+ ];
89
+ $ actual = $ this ->driver ->readDirectoryRecursively ($ destinationDirectory );
90
+ $ this ->assertEquals ($ paths , $ actual );
91
+ }
92
+
67
93
/**
68
94
* Tests directory recursive read.
69
95
*
Original file line number Diff line number Diff line change @@ -254,7 +254,10 @@ private function mkdirRecursive($path, $permissions = 0777)
254
254
public function readDirectory ($ path )
255
255
{
256
256
try {
257
- $ flags = \FilesystemIterator::SKIP_DOTS | \FilesystemIterator::UNIX_PATHS ;
257
+ $ flags = \FilesystemIterator::SKIP_DOTS |
258
+ \FilesystemIterator::UNIX_PATHS |
259
+ \RecursiveDirectoryIterator::FOLLOW_SYMLINKS ;
260
+
258
261
$ iterator = new \FilesystemIterator ($ path , $ flags );
259
262
$ result = [];
260
263
/** @var \FilesystemIterator $file */
@@ -946,7 +949,10 @@ protected function getScheme($scheme = null)
946
949
public function readDirectoryRecursively ($ path = null )
947
950
{
948
951
$ result = [];
949
- $ flags = \FilesystemIterator::SKIP_DOTS | \FilesystemIterator::UNIX_PATHS ;
952
+ $ flags = \FilesystemIterator::SKIP_DOTS |
953
+ \FilesystemIterator::UNIX_PATHS |
954
+ \RecursiveDirectoryIterator::FOLLOW_SYMLINKS ;
955
+
950
956
try {
951
957
$ iterator = new \RecursiveIteratorIterator (
952
958
new \RecursiveDirectoryIterator ($ path , $ flags ),
You can’t perform that action at this time.
0 commit comments