Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Fix bug #77022 - use file mode or umask for new files
- Loading branch information
Showing
4 changed files
with
50 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
--TEST-- | ||
Phar: Bug #77022: PharData always creates new files with mode 0666 | ||
--SKIPIF-- | ||
<?php if (!extension_loaded("phar")) die("skip"); ?> | ||
--FILE-- | ||
<?php | ||
umask(022); | ||
var_dump(decoct(umask())); | ||
|
||
$sFile = tempnam(__DIR__, 'test77022'); | ||
var_dump(decoct(stat($sFile)['mode'])); | ||
|
||
foreach([Phar::TAR => 'tar', Phar::ZIP => 'zip'] as $mode => $ext) { | ||
$phar = new PharData(__DIR__ . '/test77022.' . $ext, null, null, $mode); | ||
$phar->addFile($sFile, 'test-file-phar'); | ||
$phar->addFromString("test-from-string", 'test-file-phar'); | ||
$phar->extractTo(__DIR__); | ||
var_dump(decoct(stat(__DIR__ . '/test-file-phar')['mode'])); | ||
This comment has been minimized.
Sorry, something went wrong.
This comment has been minimized.
Sorry, something went wrong.
This comment has been minimized.
Sorry, something went wrong. |
||
var_dump(decoct(stat(__DIR__ . '/test-from-string')['mode'])); | ||
unlink(__DIR__ . '/test-file-phar'); | ||
unlink(__DIR__ . '/test-from-string'); | ||
unlink(__DIR__ . '/test77022.' . $ext); | ||
} | ||
unlink($sFile); | ||
?> | ||
--EXPECT-- | ||
string(2) "22" | ||
string(6) "100600" | ||
string(6) "100600" | ||
string(6) "100644" | ||
string(6) "100600" | ||
string(6) "100644" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Isn’t a clearstatcache call required here, since you call stat on the very same path in this loop?