Skip to content

[Filesystem] Fixed a bug in remove() being unable to unlink broken symlinks #3811

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

Merged
merged 15 commits into from
Apr 7, 2012
Merged
Show file tree
Hide file tree
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
17 changes: 11 additions & 6 deletions src/Symfony/Component/Filesystem/Filesystem.php
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@ public function mkdir($dirs, $mode = 0777)
/**
* Creates empty files.
*
* @param string|array|\Traversable $files A filename, an array of files, or a \Traversable instance to remove
* @param string|array|\Traversable $files A filename, an array of files, or a \Traversable instance to create
*/
public function touch($files)
{
Expand All @@ -88,7 +88,7 @@ public function remove($files)
$files = iterator_to_array($this->toIterator($files));
$files = array_reverse($files);
foreach ($files as $file) {
if (!file_exists($file)) {
if (!file_exists($file) && !is_link($file)) {
continue;
}

Expand All @@ -105,7 +105,7 @@ public function remove($files)
/**
* Change mode for an array of files or directories.
*
* @param string|array|\Traversable $files A filename, an array of files, or a \Traversable instance to remove
* @param string|array|\Traversable $files A filename, an array of files, or a \Traversable instance to change mode
* @param integer $mode The new mode
* @param integer $umask The mode mask (octal)
*/
Expand Down Expand Up @@ -171,16 +171,16 @@ public function symlink($originDir, $targetDir, $copyOnWindows = false)
/**
* Given an existing path, convert it to a path relative to a given starting path
*
* @var string Absolute path of target
* @var string Absolute path where traversal begins
* @param string $endPath Absolute path of target
* @param string $startPath Absolute path where traversal begins
*
* @return string Path of target relative to starting path
*/
public function makePathRelative($endPath, $startPath)
{
// Find for which character the the common path stops
$offset = 0;
while ($startPath[$offset] === $endPath[$offset]) {
while (isset($startPath[$offset]) && isset($endPath[$offset]) && $startPath[$offset] === $endPath[$offset]) {
$offset++;
}

Expand Down Expand Up @@ -264,6 +264,11 @@ public function isAbsolutePath($file)
return false;
}

/**
* @param mixed $files
*
* @return \Traversable
*/
private function toIterator($files)
{
if (!$files instanceof \Traversable) {
Expand Down
Loading
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy