1
0
Fork 0

8330 Correct issue where permission umask of files were not set when archiving in zip format with ZipArchiver

pull/8331/head
James Ho 2019-09-17 14:30:31 +01:00
parent a066dd9e00
commit 91732eee55
1 changed files with 12 additions and 0 deletions

View File

@ -45,6 +45,18 @@ class ZipArchiver implements ArchiverInterface
} else {
$zip->addFile($filepath, $localname);
}
/**
* ZipArchive::setExternalAttributesName is available from >= PHP 5.6
*/
if (PHP_VERSION_ID >= 50600) {
$perms = fileperms($filepath);
/**
* Ensure to preserve the permission umasks for the filepath in the archive.
*/
$zip->setExternalAttributesName($localname, ZipArchive::OPSYS_UNIX, $perms << 16);
}
}
if ($zip->close()) {
return $target;