8000 bug #21823 dumpFile(), preserve existing file permissions (chs2) · symfony/symfony@c91db73 · GitHub
[go: up one dir, main page]

Skip to content
8000

Commit c91db73

Browse files
committed
bug #21823 dumpFile(), preserve existing file permissions (chs2)
This PR was squashed before being merged into the 2.7 branch (closes #21823). Discussion ---------- dumpFile(), preserve existing file permissions When calling Filesystem::dumpFile() on an already existing file, its permissions are lost. | Q | A | ------------- | --- | Branch? | master | Bug fix? | yes | New feature? | no | BC breaks? | no | Deprecations? | no | Tests pass? | yes | Fixed tickets | #... <!-- #-prefixed issue number(s), if any --> | License | MIT | Doc PR | symfony/symfony-docs#... <!--highly recommended for new features--> <!-- - Bug fixes must be submitted against the lowest branch where they apply (lowest branches are regularly merged to upper ones so they get the fixes too). - Features and deprecations must be submitted against the master branch. - Please fill in this template according to the PR you're about to submit. - Replace this comment by a description of what your PR is solving. --> Commits ------- 040a9ab dumpFile(), preserve existing file permissions
2 parents 3effed8 + 040a9ab commit c91db73

File tree

1 file changed

+3
-0
lines changed

1 file changed

+3
-0
lines changed

src/Symfony/Component/Filesystem/Filesystem.php

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -516,7 +516,10 @@ 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());
519521
}
522+
520523
$this->rename($tmpFile, $filename, true);
521524
}
522525

0 commit comments

Comments
 (0)
0