Skip to content

Commit ebb510c

Browse files
[Filesystem] Fix false positive in ->remove()
1 parent 6d5dbf7 commit ebb510c

File tree

2 files changed

+7
-7
lines changed

2 files changed

+7
-7
lines changed

src/Symfony/Component/Filesystem/Filesystem.php

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -156,9 +156,9 @@ public function remove($files)
156156
$error = error_get_last();
157157
throw new IOException(sprintf('Failed to remove directory "%s": %s.', $file, $error['message']));
158158
}
159-
} elseif ($this->exists($file)) {
160-
if (!@unlink($file)) {
161-
$error = error_get_last();
159+
} elseif (!@unlink($file)) {
160+
$error = error_get_last();
161+
if (file_exists($file)) {
162162
throw new IOException(sprintf('Failed to remove file "%s": %s.', $file, $error['message']));
163163
}
164164
}

src/Symfony/Component/Filesystem/Tests/FilesystemTest.php

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -38,8 +38,7 @@ public static function setUpBeforeClass()
3838
if ('\\' === DIRECTORY_SEPARATOR && null === self::$symlinkOnWindows) {
3939
$target = tempnam(sys_get_temp_dir(), 'sl');
4040
$link = sys_get_temp_dir().'/sl'.microtime(true).mt_rand();
41-
if (@symlink($target, $link)) {
42-
self::$symlinkOnWindows = @is_link($link);
41+
if (self::$symlinkOnWindows = @symlink($target, $link)) {
4342
unlink($link);
4443
}
4544
unlink($target);
@@ -61,6 +60,7 @@ protected function tearDown()
6160
foreach ($this->longPathNamesWindows as $path) {
6261
exec('DEL '.$path);
6362
}
63+
$this->longPathNamesWindows = array();
6464
}
6565

6666
$this->filesystem->remove($this->workspace);
@@ -350,7 +350,7 @@ public function testRemoveCleansInvalidLinks()
350350

351351
// create symlink to nonexistent dir
352352
rmdir($basePath.'dir');
353-
$this->assertFalse(is_dir($basePath.'dir-link'));
353+
$this->assertFalse(@readlink($basePath.'dir-link'));
354354

355355
$this->filesystem->remove($basePath);
356356

@@ -1089,7 +1089,7 @@ private function markAsSkippedIfChmodIsMissing()
10891089

10901090
private function markAsSkippedIfPosixIsMissing()
10911091
{
1092-
if ('\\' === DIRECTORY_SEPARATOR || !function_exists('posix_isatty')) {
1092+
if (!function_exists('posix_isatty')) {
10931093
$this->markTestSkipped('POSIX is not supported');
10941094
}
10951095
}

0 commit comments

Comments
 (0)
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