Skip to content
Closed
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
6 changes: 3 additions & 3 deletions Filesystem.php
Original file line number Diff line number Diff line change
Expand Up @@ -192,12 +192,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), 0, null, $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 Tests/FilesystemTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -483,6 +483,22 @@ public function testChmodChangesModeOfTraversableFileObject()
$this->assertFilePermissions(753, $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