symfony/symfony — pull request #3844 by jakzal (2012-04-09 14:26:47+00:00)
Title: [Filesystem] Prevented infinite loop on windows while mirrorring symlinks

First check for filetype in *mirror()* method is:

if (is_link($file)) {
$this->symlink($file, $target);

later we see:

} elseif (is_file($file) || ($copyOnWindows && is_link($file))) {
$this->copy($file, $target, isset($options['override']) ? $options['override'] : false);

The later check for links on windows (*$copyOnWindows && is_link($file)*) won't ever get called. Calling *symlink()* in *mirror()* on windows would lead to calling *mirror()* again.

Note that I didn't actually try running it on windows platform. I added a test for mirroring symlinks (non-windows test). I think it'd be good if someone added some windows specific tests to this class.

I also modified the target path:

$target = $targetDir.'/'.str_replace($originDir.DIRECTORY_SEPARATOR, '', $file->getPathname());

It didn't use DIRECTORY_SEPARATOR and is equivalent to:

$target = str_replace($originDir, $targetDir, $file->getPathname());