Skip to content

Commit

Permalink
[Filesystem] Recursivly widen non-executable directories
Browse files Browse the repository at this point in the history
  • Loading branch information
Slamdunk authored and fabpot committed Dec 18, 2015
1 parent f371445 commit fb75651
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 3 deletions.
6 changes: 3 additions & 3 deletions src/Symfony/Component/Filesystem/Filesystem.php
Expand Up @@ -177,12 +177,12 @@ public function remove($files)
public function chmod($files, $mode, $umask = 0000, $recursive = false)
{
foreach ($this->toIterator($files) as $file) {
if ($recursive && is_dir($file) && !is_link($file)) {
$this->chmod(new \FilesystemIterator($file), $mode, $umask, true);
}
if (true !== @chmod($file, $mode & ~$umask)) {
throw new IOException(sprintf('Failed to chmod file %s', $file));
}
if ($recursive && is_dir($file) && !is_link($file)) {
$this->chmod(new \FilesystemIterator($file), $mode, $umask, true);
}
}
}

Expand Down
16 changes: 16 additions & 0 deletions src/Symfony/Component/Filesystem/Tests/FilesystemTest.php
Expand Up @@ -479,6 +479,22 @@ public function testChmodChangesModeOfTraversableFileObject()
$this->assertEquals(753, $this->getFilePermissions($directory));
}

public function testChmodChangesZeroModeOnSubdirectoriesOnRecursive()
{
$this->markAsSkippedIfChmodIsMissing();

$directory = $this->workspace.DIRECTORY_SEPARATOR.'directory';
$subdirectory = $directory.DIRECTORY_SEPARATOR.'subdirectory';

mkdir($directory);
mkdir($subdirectory);
chmod($subdirectory, 0000);

$this->filesystem->chmod($directory, 0753, 0000, true);

$this->assertFilePermissions(753, $subdirectory);
}

public function testChown()
{
$this->markAsSkippedIfPosixIsMissing();
Expand Down

0 comments on commit fb75651

Please sign in to comment.