1--TEST-- 2Phar: Bug #77022: PharData always creates new files with mode 0666 3--SKIPIF-- 4<?php 5if (!extension_loaded("phar")) die("skip"); 6if (defined("PHP_WINDOWS_VERSION_MAJOR")) die("skip not for Windows") 7?> 8--FILE-- 9<?php 10umask(022); 11var_dump(decoct(umask())); 12 13$sFile = tempnam(__DIR__, 'test77022'); 14var_dump(decoct(stat($sFile)['mode'])); 15 16foreach([Phar::TAR => 'tar', Phar::ZIP => 'zip'] as $mode => $ext) { 17 clearstatcache(); 18 $phar = new PharData(__DIR__ . '/test77022.' . $ext, null, null, $mode); 19 $phar->addFile($sFile, 'test-file-phar'); 20 $phar->addFromString("test-from-string", 'test-file-phar'); 21 $phar->extractTo(__DIR__); 22 var_dump(decoct(stat(__DIR__ . '/test-file-phar')['mode'])); 23 var_dump(decoct(stat(__DIR__ . '/test-from-string')['mode'])); 24 unlink(__DIR__ . '/test-file-phar'); 25 unlink(__DIR__ . '/test-from-string'); 26 unlink(__DIR__ . '/test77022.' . $ext); 27} 28unlink($sFile); 29?> 30--EXPECT-- 31string(2) "22" 32string(6) "100600" 33string(6) "100600" 34string(6) "100644" 35string(6) "100600" 36string(6) "100644"