Skip to content

Commit 1a09c6a

Browse files
committed
[Filesystem] deprecate chmod support in dumpFile()
The ability to support a custom permission mask in the `dumpFile()` method is deprecated since Symfony Symfony 2.3.12. This commit adds the `error_trigger()` call if a custom permission mask is passed.
1 parent c16930f commit 1a09c6a

File tree

2 files changed

+17
-0
lines changed

2 files changed

+17
-0
lines changed

src/Symfony/Component/Filesystem/Filesystem.php

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -480,6 +480,10 @@ public function dumpFile($filename, $content, $mode = 0666)
480480

481481
$this->rename($tmpFile, $filename, true);
482482
if (null !== $mode) {
483+
if (func_num_args() > 2) {
484+
trigger_error('Support for modifying file permissions is deprecated since version 2.3.12 and will be removed in 3.0.', E_USER_DEPRECATED);
485+
}
486+
483487
$this->chmod($filename, $mode);
484488
}
485489
}

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

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -959,6 +959,19 @@ public function testDumpFile()
959959
{
960960
$filename = $this->workspace.DIRECTORY_SEPARATOR.'foo'.DIRECTORY_SEPARATOR.'baz.txt';
961961

962+
$this->filesystem->dumpFile($filename, 'bar');
963+
964+
$this->assertFileExists($filename);
965+
$this->assertSame('bar', file_get_contents($filename));
966+
}
967+
968+
/**
969+
* @group legacy
970+
*/
971+
public function testDumpFileAndSetPermissions()
972+
{
973+
$filename = $this->workspace.DIRECTORY_SEPARATOR.'foo'.DIRECTORY_SEPARATOR.'baz.txt';
974+
962975
$this->filesystem->dumpFile($filename, 'bar', 0753);
963976

964977
$this->assertFileExists($filename);

0 commit comments

Comments
 (0)