File tree 2 files changed +17
-1
lines changed
src/Symfony/Component/Filesystem
2 files changed +17
-1
lines changed Original file line number Diff line number Diff line change @@ -88,7 +88,7 @@ public function remove($files)
88
88
$ files = iterator_to_array ($ this ->toIterator ($ files ));
89
89
$ files = array_reverse ($ files );
90
90
foreach ($ files as $ file ) {
91
- if (!file_exists ($ file )) {
91
+ if (!file_exists ($ file ) && ! is_link ( $ file ) ) {
92
92
continue ;
93
93
}
94
94
Original file line number Diff line number Diff line change @@ -297,6 +297,22 @@ public function testRemoveIgnoresNonExistingFiles()
297
297
$ this ->assertTrue (!is_dir ($ basePath .'dir ' ));
298
298
}
299
299
300
+ public function testRemoveCleansInvalidLinks ()
301
+ {
302
+ $ this ->markAsSkippeIfSymlinkIsMissing ();
303
+
304
+ $ basePath = $ this ->workspace .DIRECTORY_SEPARATOR .'directory ' .DIRECTORY_SEPARATOR ;
305
+
306
+ mkdir ($ basePath );
307
+ mkdir ($ basePath .'dir ' );
308
+ // create symlink to unexisting file
309
+ symlink ($ basePath .'file ' , $ basePath .'link ' );
310
+
311
+ $ this ->filesystem ->remove ($ basePath );
312
+
313
+ $ this ->assertTrue (!is_dir ($ basePath ));
314
+ }
315
+
300
316
public function testChmodChangesFileMode ()
301
317
{
302
318
$ file = $ this ->workspace .DIRECTORY_SEPARATOR .'file ' ;
You can’t perform that action at this time.
0 commit comments