Skip to content

Commit

Permalink
minor #14460 [Filesystem] deprecate chmod support in dumpFile() (xabbuh)
Browse files Browse the repository at this point in the history
This PR was merged into the 2.7 branch.

Discussion
----------

[Filesystem] deprecate chmod support in dumpFile()

| Q             | A
| ------------- | ---
| Bug fix?      | no
| New feature?  | no
| BC breaks?    | no
| Deprecations? | yes
| Tests pass?   | yes
| Fixed tickets |
| License       | MIT
| Doc PR        |

The ability to support a custom permission mask in the `dumpFile()` method is deprecated since Symfony Symfony 2.3.12. This commit adds the `trigger_error()` call if a custom permission mask is passed.

Commits
-------

faee0d7 [Filesystem] deprecate chmod support in dumpFile()
  • Loading branch information
fabpot committed Apr 27, 2015
2 parents 5cc2849 + faee0d7 commit 501df8d
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 1 deletion.
4 changes: 4 additions & 0 deletions src/Symfony/Component/Filesystem/Filesystem.php
Expand Up @@ -480,6 +480,10 @@ public function dumpFile($filename, $content, $mode = 0666)

$this->rename($tmpFile, $filename, true);
if (null !== $mode) {
if (func_num_args() > 2) {
trigger_error('Support for modifying file permissions is deprecated since version 2.3.12 and will be removed in 3.0.', E_USER_DEPRECATED);
}

$this->chmod($filename, $mode);
}
}
Expand Down
15 changes: 14 additions & 1 deletion src/Symfony/Component/Filesystem/Tests/FilesystemTest.php
Expand Up @@ -19,7 +19,7 @@
class FilesystemTest extends FilesystemTestCase
{
/**
* @var \Symfony\Component\Filesystem\Filesystem $filesystem
* @var \Symfony\Component\Filesystem\Filesystem
*/
private $filesystem = null;

Expand Down Expand Up @@ -959,6 +959,19 @@ public function testDumpFile()
{
$filename = $this->workspace.DIRECTORY_SEPARATOR.'foo'.DIRECTORY_SEPARATOR.'baz.txt';

$this->filesystem->dumpFile($filename, 'bar');

$this->assertFileExists($filename);
$this->assertSame('bar', file_get_contents($filename));
}

/**
* @group legacy
*/
public function testDumpFileAndSetPermissions()
{
$filename = $this->workspace.DIRECTORY_SEPARATOR.'foo'.DIRECTORY_SEPARATOR.'baz.txt';

$this->filesystem->dumpFile($filename, 'bar', 0753);

$this->assertFileExists($filename);
Expand Down

0 comments on commit 501df8d

Please sign in to comment.