-
Notifications
You must be signed in to change notification settings - Fork 7.7k
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
ZipArchive deletes zip file with no contents and doesn't update stat cache #8781
Comments
Confirmed
This the default behavior of the libzip library, (perhaps since empty file are not valid zip archive), so nothing we can change in php
PR pending |
Fixed in standalone pecl extension |
…n't update stat cache
…n't update stat cache
See PR #8783 |
I don't think this is true. On Windows, I can create an empty.zip via the explorer, and the specification says:
"SHOULD contain" is not "MUST contain". We may consider to still create such an empty archive, even if libzip would delete the file. Or maybe upstream would reconsider the behavior for empty archives. |
I mean "empty file" (size=0) are not valid, not about "empty archive" ;) |
Yeah, but this ticket is about empty archives: $zip = new ZipArchive;
$zip->open($tmp_file, ZipArchive::OVERWRITE);
$zip->close(); // returns true |
Yes, but the example use a "empty file" (tempnam) which is not a valid archive. And indeed, the library doesn't allow to create an empty archive, but I don't think we can fix this in the extension. P.S. opening an empty archive works (and it is not deleted during the close) For memory, upstream code: https://github.com/nih-at/libzip/blob/v1.9.0/lib/zip_close.c#L65 |
Oh, right!
Thinking about it, that should really be fixed upstream. For instance, given that I have an archive, and delete some entries, after |
libzip discussion nih-at/libzip#299 |
* PHP-8.0: NEWS Fix GH-8781 ZipArchive::close deletes zip file without updating stat cache
* PHP-8.1: NEWS NEWS Fix GH-8781 ZipArchive::close deletes zip file without updating stat cache
Followup: add documentation of library expected /documented behavior in our documentation |
Description
There is a problem with ZipArchive deleting empty archives without notice upon successful close. And statcache not updated.
I expected the defined file to remain. If I can't count on that I expected the statcache to be updated.
PHP Version
PHP 8.1.6
Operating System
Windows 11 x64
The text was updated successfully, but these errors were encountered: