Repository navigation
ext/zip: use ZIP_RDONLY when calling zip_open() in zip_stream.c - #23976
Open
DanielEScherzer wants to merge 2 commits into
Open
DanielEScherzer wants to merge 2 commits into
DanielEScherzer wants to merge 2 commits into
Conversation
Member
|
The Windows CI seems related. |
A follow-up commit will switch the uses of the `ZIP_CREATE` to instead use `ZIP_RDONLY` when creation is not desired; add tests to confirm that doing so does not change the actual behavior of the extension.
The code paths that call `zip_open()` are used for stats and reading, not writing. Previously `ZIP_CREATE` would create an in-memory zip archive, and if it were written to, would persist it to disk when closed, but since the archive was never written to, this functionality was unneeded. Use the `ZIP_RDONLY` flag to make it clearer that the zip archive is not being written to.
DanielEScherzer
force-pushed
the
zip-read-only
branch
from
September 29, 2026 19:37
89bc33c to
c87f57e
Compare
LamentXU123
approved these changes
Oct 1, 2026
| $target = __FILE__; | ||
|
|
||
| echo "Stat:\n"; | ||
| var_dump(stat("zip://$target#entry1.txt")); |
Member
There was a problem hiding this comment.
I doubt this will actually test this patch. Perhaps
--TEST--
fstat() on an existing zip entry
--EXTENSIONS--
zip
--FILE--
<?php
$target = __DIR__ . '/test.zip';
$fp = fopen("zip://$target#entry1.txt", 'rb');
$stat = fstat($fp);
var_dump($stat['size']);
var_dump(stream_get_contents($fp));
fclose($fp);
?>
--EXPECT--
int(8)
string(8) "entry #1"
Member
Author
There was a problem hiding this comment.
The point of this test is the behavior of stat when using zip: for something that isn't a zip - the stats for an existing zip entry are covered by ext/zip/tests/stats_existing.phpt. Was your suggestion meant to be for that file?
Member
There was a problem hiding this comment.
Yes, sorry for the confusion :)
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
The code paths that call
zip_open()are used for stats and reading, not writing. PreviouslyZIP_CREATEwould create an in-memory zip archive, and if it were written to, would persist it to disk when closed, but since the archive was never written to, this functionality was unneeded. Use theZIP_RDONLYflag to make it clearer that the zip archive is not being written to.