Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Commit 3a7cd08

Browse filesBrowse files
committed
respect the umask argument in dumpFile()
1 parent c91db73 commit 3a7cd08
Copy full SHA for 3a7cd08

File tree

2 files changed

+15
-2
lines changed
Filter options

2 files changed

+15
-2
lines changed

‎src/Symfony/Component/Filesystem/Filesystem.php

Copy file name to clipboardExpand all lines: src/Symfony/Component/Filesystem/Filesystem.php
+2-2Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -516,8 +516,8 @@ public function dumpFile($filename, $content, $mode = 0666)
516516
}
517517

518518
$this->chmod($tmpFile, $mode);
519-
} else {
520-
@chmod($tmpFile, file_exists($filename) ? fileperms($filename) : 0666 & ~umask());
519+
} elseif (file_exists($filename)) {
520+
@chmod($tmpFile, fileperms($filename));
521521
}
522522

523523
$this->rename($tmpFile, $filename, true);

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

Copy file name to clipboardExpand all lines: src/Symfony/Component/Filesystem/Tests/FilesystemTest.php
+13Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1050,6 +1050,19 @@ public function testDumpFileOverwritesAnExistingFile()
10501050
$this->assertSame('bar', file_get_contents($filename));
10511051
}
10521052

1053+
public function testDumpKeepsExistingPermissionsWhenOverwritingAnExistingFile()
1054+
{
1055+
$this->markAsSkippedIfChmodIsMissing();
1056+
1057+
$filename = $this->workspace.DIRECTORY_SEPARATOR.'foo.txt';
1058+
file_put_contents($filename, 'FOO BAR');
1059+
chmod($filename, 0745);
1060+
1061+
$this->filesystem->dumpFile($filename, 'bar', null);
1062+
1063+
$this->assertFilePermissions(745, $filename);
1064+
}
1065+
10531066
public function testCopyShouldKeepExecutionPermission()
10541067
{
10551068
$this->markAsSkippedIfChmodIsMissing();

0 commit comments

Comments
0 (0)
Morty Proxy This is a proxified and sanitized view of the page, visit original site.