[Filesystem] Recursivly widen non-executable directories
This commit is contained in:
parent
f371445eff
commit
fb75651a81
@ -177,12 +177,12 @@ class Filesystem
|
|||||||
public function chmod($files, $mode, $umask = 0000, $recursive = false)
|
public function chmod($files, $mode, $umask = 0000, $recursive = false)
|
||||||
{
|
{
|
||||||
foreach ($this->toIterator($files) as $file) {
|
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)) {
|
if (true !== @chmod($file, $mode & ~$umask)) {
|
||||||
throw new IOException(sprintf('Failed to chmod file %s', $file));
|
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);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -479,6 +479,22 @@ class FilesystemTest extends \PHPUnit_Framework_TestCase
|
|||||||
$this->assertEquals(753, $this->getFilePermissions($directory));
|
$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()
|
public function testChown()
|
||||||
{
|
{
|
||||||
$this->markAsSkippedIfPosixIsMissing();
|
$this->markAsSkippedIfPosixIsMissing();
|
||||||
|
Reference in New Issue
Block a user