Permalink
Browse files

Fix #8205 : Deprecate file mode update when calling dumpFile

  • Loading branch information...
1 parent 0f3dacb commit 8e7c8482b6fa390b345b272cdbad1dc706fe7bd6 @romainneutron romainneutron committed with fabpot Mar 19, 2014
Showing with 28 additions and 5 deletions.
  1. +5 −0 CHANGELOG.md
  2. +8 −5 Filesystem.php
  3. +15 −0 Tests/FilesystemTest.php
View
@@ -1,6 +1,11 @@
CHANGELOG
=========
+2.3.12
+------
+
+ * deprecated dumpFile() file mode argument.
+
2.3.0
-----
View
@@ -444,10 +444,11 @@ private function toIterator($files)
/**
* Atomically dumps content into a file.
*
- * @param string $filename The file to be written to.
- * @param string $content The data to write into the file.
- * @param integer $mode The file mode (octal).
- * @throws IOException If the file cannot be written to.
+ * @param string $filename The file to be written to.
+ * @param string $content The data to write into the file.
+ * @param null|integer $mode The file mode (octal). If null, file permissions are not modified
+ * Deprecated since version 2.3.12, to be removed in 3.0.
+ * @throws IOException If the file cannot be written to.
*/
public function dumpFile($filename, $content, $mode = 0666)
{
@@ -466,6 +467,8 @@ public function dumpFile($filename, $content, $mode = 0666)
}
$this->rename($tmpFile, $filename, true);
- $this->chmod($filename, $mode);
+ if (null !== $mode) {
+ $this->chmod($filename, $mode);
+ }
}
}
@@ -925,6 +925,21 @@ public function testDumpFile()
}
}
+ public function testDumpFileWithNullMode()
+ {
+ $filename = $this->workspace.DIRECTORY_SEPARATOR.'foo'.DIRECTORY_SEPARATOR.'baz.txt';
+
+ $this->filesystem->dumpFile($filename, 'bar', null);
+
+ $this->assertFileExists($filename);
+ $this->assertSame('bar', file_get_contents($filename));
+
+ // skip mode check on Windows
+ if (!defined('PHP_WINDOWS_VERSION_MAJOR')) {
+ $this->assertEquals(600, $this->getFilePermissions($filename));
+ }
+ }
+
public function testDumpFileOverwritesAnExistingFile()
{
$filename = $this->workspace.DIRECTORY_SEPARATOR.'foo.txt';

0 comments on commit 8e7c848

Please sign in to comment.