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

Appearance settings

Try to delete broken symlinks #17626

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
[Filesystem] Try to delete broken symlinks
If you delete the target of a symlink (at least on Windows systems) you
don't get the kind of the target anymore (obviously). Therefore it might
happen that a broken symlink to a directory should be removed with
unlink() which fails. This patch adds another check for a broken symlink
and tries to remove with rmdir() before throwing an exception. It helps
to clean up test folders on Windows systems (so already proofed by the
existing tests).
  • Loading branch information
IchHabRecht committed Jan 31, 2016
commit 58dd0b9cc948756a03adb4670046e7b114204d2f
9 changes: 8 additions & 1 deletion 9 src/Symfony/Component/Filesystem/Filesystem.php
Original file line number Diff line number Diff line change
Expand Up @@ -172,7 +172,14 @@ public function remove($files)
}
} else {
if (true !== @unlink($file)) {
throw new IOException(sprintf('Failed to remove file "%s".', $file), 0, null, $file);
// handle broken symlinks on Windows systems
if (is_link($file) && false === @readlink($file)) {
if (true !== @rmdir($file)) {
throw new IOException(sprintf('Failed to remove broken symlink "%s".', $file), 0, null, $file);
}
} else {
throw new IOException(sprintf('Failed to remove file "%s".', $file), 0, null, $file);
}
}
}
}
Expand Down
Morty Proxy This is a proxified and sanitized view of the page, visit original site.