Movatterモバイル変換


[0]ホーム

URL:


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

Sign up
Appearance settings

Commit48b4bcf

Browse files
committed
bug#17063 bug#14246 [Filesystem] dumpFile() negates default file permissions (Hidde Boomsma)
This PR was merged into the 3.0 branch.Discussion----------bug#14246 [Filesystem] dumpFile() negates default file permissions| Q | A| ------------- | ---| Bug fix? | yes| New feature? | no| BC breaks? | no| Deprecations? | no| Tests pass? | yes| Fixed tickets |#14246| License | MIT| Doc PR | noneRemain BC compatible with Symfony 2.8.Without this change a chmod is needed after calling `dumpFile`, making it non atomic.Commits-------53d6d4b bug#14246 [Filesystem] dumpFile() negates default file permissions
2 parentsd14eae4 +53d6d4b commit48b4bcf

File tree

2 files changed

+5
-1
lines changed

2 files changed

+5
-1
lines changed

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

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -522,12 +522,16 @@ public function dumpFile($filename, $content)
522522
thrownewIOException(sprintf('Unable to write to the "%s" directory.',$dir),0,null,$dir);
523523
}
524524

525+
// Will create a temp file with 0600 access rights
526+
// when the filesystem supports chmod.
525527
$tmpFile =$this->tempnam($dir,basename($filename));
526528

527529
if (false === @file_put_contents($tmpFile,$content)) {
528530
thrownewIOException(sprintf('Failed to write file "%s".',$filename),0,null,$filename);
529531
}
530532

533+
// Ignore for filesystems that do not support umask
534+
@chmod($tmpFile,0666);
531535
$this->rename($tmpFile,$filename,true);
532536
}
533537

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1076,7 +1076,7 @@ public function testDumpFile()
10761076

10771077
// skip mode check on Windows
10781078
if ('\\' !==DIRECTORY_SEPARATOR) {
1079-
$this->assertFilePermissions(600,$filename);
1079+
$this->assertFilePermissions(666,$filename);
10801080
}
10811081
}
10821082

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp