Преглед на файлове

Merge pull request #8331 from jimmy-ho/bug/issue-8330

8330 Correct issue where permission umask of files were not set when …
Jordi Boggiano преди 5 години
родител
ревизия
c3d3d45903
променени са 1 файла, в които са добавени 12 реда и са изтрити 0 реда
  1. 12 0
      src/Composer/Package/Archiver/ZipArchiver.php

+ 12 - 0
src/Composer/Package/Archiver/ZipArchiver.php

@@ -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;