File tree Expand file tree Collapse file tree 2 files changed +17
-1
lines changed
src/Symfony/Component/Filesystem Expand file tree Collapse file tree 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)
8888 $ files = iterator_to_array ($ this ->toIterator ($ files ));
8989 $ files = array_reverse ($ files );
9090 foreach ($ files as $ file ) {
91- if (!file_exists ($ file )) {
91+ if (!file_exists ($ file ) && ! is_link ( $ file ) ) {
9292 continue ;
9393 }
9494
Original file line number Diff line number Diff line change @@ -297,6 +297,22 @@ public function testRemoveIgnoresNonExistingFiles()
297297 $ this ->assertTrue (!is_dir ($ basePath .'dir ' ));
298298 }
299299
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+
300316 public function testChmodChangesFileMode ()
301317 {
302318 $ file = $ this ->workspace .DIRECTORY_SEPARATOR .'file ' ;
You can’t perform that action at this time.
0 commit comments