-
Notifications
You must be signed in to change notification settings - Fork 304
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
taskPack modified to correctly set file permissions in ZIP files on Unix and on Windows NTFS #897
base: 1.x
Are you sure you want to change the base?
Conversation
…nix and on Windows NTFS
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please use octal for chmod constants.
Tests would be nice-to-have.
$zip->setExternalAttributesName( | ||
"{$placementLocation}/{$relativePathname}", | ||
\ZipArchive::OPSYS_WINDOWS_NTFS, | ||
33188 // Is the decimal for 100644 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This would be clearer if expressed in octal (0100644
).
I guess there is no +x bit on Windows? is-executable returns true
only for .exe
files, which is pointless on Linux. I guess manipulating Linux files on a Windows system just has to be an edge case that we don't / can't support.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Using Octal expression doesn't work on Windows, it seems only decimal values work on windows via setExternalAttributesName().
And this is not an edge case, many of the PHP devs develop on windows and may create an archive to distribute on linux servers. It causes a huge problem, like if the index/root file has a permission of 0666, it shows an 403 forbidden error when accessed via HTTP and file compressed via Robo in windows has 0666 permission for all the files(except directories, they have 0755).
So, I guess it would be an essential things to implement, I'm using this locally and it's working for me and someone may face the same issue in future that's why I created the pull request, it's your choice if you want to merge or not.
Thanks.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
What do you get when you run this on Windows?
php -r 'print 0100644;'
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
By saying octal expression doesn't work on windows I meant about the setExternalAttributesName(); method's parameter, not the OS entirely.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
That seems impossible to me; regardless of whether you represent a number in octal or decimal in the source, the data passed to a method parameter should be the same. Can you explain why setExternalAttributesName()
fails with an octal parameter? What is at work here?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please provide a test.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It seems it's an internal bug of PHP, besides setExternalAttributesName() isn't properly documented, the only example they provided is for the unix system and while on windows the octal values doesn't change the permission as expected, I'm kinda busy to write the tests, and I'm not sure what to tests against, as extracting the zip on windows to check if the has the permission of 0644 or not won't work on Windows because that's not how windows permissions work at all.
I'm closing this, thanks.
Maybe someone else will want to move this forward later. The behavior of |
Overview
This pull request:
Summary
taskPack modified to correctly set file permissions in ZIP files on Unix and on Windows NTFS.
Description
Without these changes, on any *nix or Windows system, created ZIP files stores the files with the permission there is no way to change it. This fix adds code to automatically set permissions in archive same to permissions of original files for *nix systems. And since on Windows the file permissions are different and even keeping the original permissions doesn't work there. So, it sets the files permissions to 0644 by default on Windows.
Referenced here but the pull wasn't merged because of the coding style issue. I fixed it and added the Windows system workaround.
#888