Repository navigation
feat(ext): add Zip support on libzip with php-src fixtures - #2193
Guikingone wants to merge 1 commit into
Conversation
Zip support with php-src fixtures
bc43213 to
8303241
Compare
Zip support with php-src fixtures5b100c9 to
7fe7269
Compare
7fe7269 to
7173345
Compare
7173345 to
998ca9c
Compare
| s_foreach(e_call("explode", vec![e_str(":"), e_var("allowed")]), None, "root", vec![ | ||
| s_if( | ||
| e_binop(e_binop(e_var("root"), BinOp::StrictNotEq, e_str("")), BinOp::And, e_call("str_starts_with", vec![e_var("pattern"), e_var("root")])), | ||
| vec![ | ||
| s_assign("inside", e_bool(true)), |
There was a problem hiding this comment.
Restricted paths escape their folder. The
open_basedir check accepts any raw path starting with the allowed text. With /srv/data allowed, /srv/data-old/*.txt and /srv/data/../private/*.txt pass. The matches then reach addFile() without another folder check, so their contents enter the archive. Check each resolved file against resolved allowed directories, including a directory boundary. addPattern() needs the same check.
How this was verified: The prefix check feeds raw matches into addFile(), and the native read path has no further open_basedir check.
Prompt To Fix With AI
This is a comment left during a code review.
Path: src/zip_prelude/build.rs
Line: 2215-2219
Comment:
**Restricted paths escape their folder.** The `open_basedir` check accepts any raw path starting with the allowed text. With `/srv/data` allowed, `/srv/data-old/*.txt` and `/srv/data/../private/*.txt` pass. The matches then reach `addFile()` without another folder check, so their contents enter the archive. Check each resolved file against resolved allowed directories, including a directory boundary. `addPattern()` needs the same check.
**How this was verified:** The prefix check feeds raw matches into `addFile()`, and the native read path has no further `open_basedir` check.
---
For each issue above, determine whether it is valid and should be fixed. If so, fix it directly.| emitter.instruction("ldr x10, [sp, #72]"); // reload the handle slot | ||
| abi::emit_symbol_address(emitter, "x3", "_zip_stream_uri"); // URI buffer base | ||
| emitter.instruction("add x3, x3, x10, lsl #8"); // slot * 256 | ||
| abi::emit_symbol_address(emitter, "x9", "_zip_stream_uri_len"); // URI length table | ||
| emitter.instruction("ldr x4, [x9, x10, lsl #3]"); // stored URI length | ||
| emitter.instruction("mov x5, #1"); // value tag = string | ||
| emit_hash_put_aarch64(emitter, "_meta_key_uri", 3); |
There was a problem hiding this comment.
Saved stream URLs change. The returned metadata stores
uri as a pointer into the reusable _zip_stream_uri buffer. __rt_hash_set copies the key, not the string value. Saving the metadata, closing the stream, and opening another wrapper in the same slot changes the old metadata's URL while keeping its old length. Copy the URL into owned string storage before putting it in the returned array.
Prompt To Fix With AI
This is a comment left during a code review.
Path: src/codegen_support/runtime/io/stream_get_meta_data.rs
Line: 73-79
Comment:
**Saved stream URLs change.** The returned metadata stores `uri` as a pointer into the reusable `_zip_stream_uri` buffer. `__rt_hash_set` copies the key, not the string value. Saving the metadata, closing the stream, and opening another wrapper in the same slot changes the old metadata's URL while keeping its old length. Copy the URL into owned string storage before putting it in the returned array.
---
For each issue above, determine whether it is valid and should be fixed. If so, fix it directly.| s_assign("archive", e_index(e_index(e_static_prop("__ElephcZipProcedural", "state"), e_var("id")), e_int(0))), | ||
| s_static_prop_array_assign("__ElephcZipProcedural", "state", e_var("id"), e_null()), | ||
| s_expr(e_method_call(e_var("archive"), "close", vec![])), |
There was a problem hiding this comment.
Closed ZIP handles stay open.
zip_open() and zip_read() allocate real temporary-file resources, but zip_close() and zip_entry_close() only clear their saved state. Neither closes the returned resource. Keeping references to already-closed handles therefore keeps their OS files open until those values are dropped. Close the backing resources when the procedural close functions run.
Prompt To Fix With AI
This is a comment left during a code review.
Path: src/zip_prelude/build.rs
Line: 2982-2984
Comment:
**Closed ZIP handles stay open.** `zip_open()` and `zip_read()` allocate real temporary-file resources, but `zip_close()` and `zip_entry_close()` only clear their saved state. Neither closes the returned resource. Keeping references to already-closed handles therefore keeps their OS files open until those values are dropped. Close the backing resources when the procedural close functions run.
---
For each issue above, determine whether it is valid and should be fixed. If so, fix it directly.| - `addPattern()` accepts the PCRE subset the crate's `regex` engine understands and | ||
| matches names byte-wise like PCRE without the `u` modifier (the `u` modifier enables | ||
| Unicode matching). `i`, `m`, `s`, `x`, `u` and `A` are honored; `U` (ungreedy) has no | ||
| Rust-regex equivalent and is rejected rather than silently matched greedily. Lookarounds | ||
| and backreferences that only PCRE2 can evaluate are also rejected with | ||
| `ZipArchive::addPattern(): Invalid expression`. | ||
| - `addGlob()` honors `GLOB_BRACE`; the remaining `GLOB_*` ordering/only-directory | ||
| flags are not represented by the compiler's `glob()`. |
There was a problem hiding this comment.
Required documentation is missing.
AGENTS.md requires known PHP differences in docs/php/types.md and compiler-internal changes in docs/internals/. This PR adds ZIP differences and shared stream-runtime changes but updates neither location. Add the ZIP compatibility entry and document the new stream metadata storage and wrapper read path in the relevant internal guide.
Context Used: AGENTS.md (source)
Prompt To Fix With AI
This is a comment left during a code review.
Path: docs/php/zip.md
Line: 122-129
Comment:
**Required documentation is missing.** `AGENTS.md` requires known PHP differences in `docs/php/types.md` and compiler-internal changes in `docs/internals/`. This PR adds ZIP differences and shared stream-runtime changes but updates neither location. Add the ZIP compatibility entry and document the new stream metadata storage and wrapper read path in the relevant internal guide.
**Context Used:** AGENTS.md ([source](https://github.com/illegalstudio/elephc/blob/main/AGENTS.md))
---
For each issue above, determine whether it is valid and should be fixed. If so, fix it directly.Note: If this suggestion doesn't match your team's coding style, reply to this and let me know. I'll remember it for next time!
0ef4f3b to
0a6b96c
Compare
| emitter.instruction("bl __rt_stream_get_contents"); // x1/x2 = accumulated wrapper payload | ||
| emitter.instruction("stp x1, x2, [sp, #24]"); // preserve the result across close | ||
| emitter.instruction("bl __rt_str_persist"); // adopt scratch bytes into an owned result | ||
| emitter.instruction("stp x1, x2, [sp, #24]"); // persist any moved pointer/length | ||
| emitter.instruction("ldr x0, [sp, #16]"); // reload the synthetic fd | ||
| emitter.instruction("bl __rt_user_wrapper_fclose"); // run stream_close and release the handle slot |
There was a problem hiding this comment.
Failed reads leave streams open. If
stream_read() or stream_eof() throws, file_get_contents() skips its only call to __rt_user_wrapper_fclose. The hidden stream stays in _user_wrapper_handles. Repeated caught failures can fill all 256 slots and prevent later wrapper streams from opening. Add cleanup for escaping exceptions on both targets.
Prompt To Fix With AI
This is a comment left during a code review.
Path: src/codegen_support/runtime/io/file_get_contents_wrapper.rs
Line: 53-58
Comment:
**Failed reads leave streams open.** If `stream_read()` or `stream_eof()` throws, `file_get_contents()` skips its only call to `__rt_user_wrapper_fclose`. The hidden stream stays in `_user_wrapper_handles`. Repeated caught failures can fill all 256 slots and prevent later wrapper streams from opening. Add cleanup for escaping exceptions on both targets.
---
For each issue above, determine whether it is valid and should be fixed. If so, fix it directly.| s_if( | ||
| e_binop(e_call("elephc_zip_result_ok", vec![]), BinOp::StrictEq, e_int(1)), | ||
| vec![ | ||
| s_prop_assign(e_this(), "__elephc_comment", e_call("hex2bin", vec![e_var("comment")])), | ||
| ], | ||
| vec![], | ||
| None, | ||
| ), |
There was a problem hiding this comment.
Removed comments stay visible. Clearing an archive comment leaves
$zip->comment showing the old text. __elephc_refresh() updates the saved property only when elephc_zip_result_ok() is true, but removing the comment makes archive_comment() return None. Reset the saved property to an empty string when there is no comment.
Prompt To Fix With AI
This is a comment left during a code review.
Path: src/zip_prelude/build.rs
Line: 782-789
Comment:
**Removed comments stay visible.** Clearing an archive comment leaves `$zip->comment` showing the old text. `__elephc_refresh()` updates the saved property only when `elephc_zip_result_ok()` is true, but removing the comment makes `archive_comment()` return `None`. Reset the saved property to an empty string when there is no comment.
---
For each issue above, determine whether it is valid and should be fixed. If so, fix it directly.| ( | ||
| "zip_open", | ||
| "a deprecated procedural alias implemented by the zip prelude over ZipArchive. It has \ | ||
| no `builtin!` binding and no `eval_builtin!` home; the prelude is the whole \ | ||
| implementation. The comparison table therefore counts the zip module from the \ | ||
| registry (0/10), while ZipArchive and the procedural API remain prelude-provided.", | ||
| ), |
There was a problem hiding this comment.
ZIP contracts go unchecked. The new
zip_* entries join UNCONTRACTED_PRELUDE_DECLARATIONS instead of receiving shared contracts. CONTRIBUTING.md requires functions supplied by a prelude to have BuiltinKind::PreludeProvided contracts, even without a builtin! or eval_builtin! binding. Add the contracts for all ten functions before merging so their signatures receive the required checks.
Context Used: AGENTS.md (source)
Prompt To Fix With AI
This is a comment left during a code review.
Path: src/builtins/parity_tests.rs
Line: 252-258
Comment:
**ZIP contracts go unchecked.** The new `zip_*` entries join `UNCONTRACTED_PRELUDE_DECLARATIONS` instead of receiving shared contracts. `CONTRIBUTING.md` requires functions supplied by a prelude to have `BuiltinKind::PreludeProvided` contracts, even without a `builtin!` or `eval_builtin!` binding. Add the contracts for all ten functions before merging so their signatures receive the required checks.
**Context Used:** AGENTS.md ([source](https://github.com/illegalstudio/elephc/blob/main/AGENTS.md))
---
For each issue above, determine whether it is valid and should be fixed. If so, fix it directly.| if ! command -v cmake >/dev/null 2>&1; then | ||
| if command -v elephc-ci-apt-install >/dev/null 2>&1; then | ||
| elephc-ci-apt-install --no-install-recommends cmake |
There was a problem hiding this comment.
Pinned jobs install missing packages. This producer installs
cmake inside the pinned CI image when it is missing. CONTRIBUTING.md requires a missing dependency in a pinned test environment to fail rather than trigger package installation. Publish and select an image containing cmake, then remove this runtime install before merging. The ARM64 producer has the same pattern.
Context Used: AGENTS.md (source)
Prompt To Fix With AI
This is a comment left during a code review.
Path: .github/workflows/ci-build-host.yml
Line: 720-722
Comment:
**Pinned jobs install missing packages.** This producer installs `cmake` inside the pinned CI image when it is missing. `CONTRIBUTING.md` requires a missing dependency in a pinned test environment to fail rather than trigger package installation. Publish and select an image containing `cmake`, then remove this runtime install before merging. The ARM64 producer has the same pattern.
**Context Used:** AGENTS.md ([source](https://github.com/illegalstudio/elephc/blob/main/AGENTS.md))
---
For each issue above, determine whether it is valid and should be fixed. If so, fix it directly.271b4a5 to
9e04fc0
Compare
| s_if( | ||
| e_call("isset", vec![e_index(e_var("options"), e_str("enc_method"))]), | ||
| vec![ | ||
| s_expr(e_method_call(e_this(), "setEncryptionName", vec![e_var("entry"), e_cast(CastType::Int, e_index(e_var("options"), e_str("enc_method"))), e_ternary(e_call("isset", vec![e_index(e_var("options"), e_str("enc_password"))]), e_cast(CastType::String, e_index(e_var("options"), e_str("enc_password"))), e_null())])), |
There was a problem hiding this comment.
Encryption failures look successful
__elephc_add_matches() ignores failed encryption and compression calls, then returns the file in its success list. An enc_password containing a NUL byte is rejected by CString::new() before encryption is set, but addGlob() still reports success and leaves the added entry unencrypted. Check both return values and return failure before adding the file to the success list.
How this was verified: The password rejection happens before zip_file_set_encryption(), while the caller drops the failed result and keeps the added entry.
Prompt To Fix With AI
This is a comment left during a code review.
Path: src/zip_prelude/build.rs
Line: 2187
Comment:
**Encryption failures look successful**
`__elephc_add_matches()` ignores failed encryption and compression calls, then returns the file in its success list. An `enc_password` containing a NUL byte is rejected by `CString::new()` before encryption is set, but `addGlob()` still reports success and leaves the added entry unencrypted. Check both return values and return failure before adding the file to the success list.
**How this was verified:** The password rejection happens before `zip_file_set_encryption()`, while the caller drops the failed result and keeps the added entry.
---
For each issue above, determine whether it is valid and should be fixed. If so, fix it directly.| if let Some(stream_type) = self.zip_stream_method_return(class_name, method) { | ||
| self.infer_method_call_on_class_type(class_name, method, args, expr, env)?; | ||
| return Ok(stream_type); |
There was a problem hiding this comment.
zip_stream_method_return() forces resource|false onto user overrides too. A subclass may legally declare getStream(string $name): string, because the parent method has no declared return type. Calls to that override still lose their actual string type here. This can reject valid typed uses or send the wrong value shape downstream. Apply this special case only when the selected method is the inherited ZIP implementation.
Prompt To Fix With AI
This is a comment left during a code review.
Path: src/types/checker/inference/objects/methods.rs
Line: 89-91
Comment:
**ZIP overrides get wrong types**
`zip_stream_method_return()` forces `resource|false` onto user overrides too. A subclass may legally declare `getStream(string $name): string`, because the parent method has no declared return type. Calls to that override still lose their actual string type here. This can reject valid typed uses or send the wrong value shape downstream. Apply this special case only when the selected method is the inherited ZIP implementation.
---
For each issue above, determine whether it is valid and should be fixed. If so, fix it directly.|
|
||
| /// `ZipArchive` — transcribed from the PHP form. | ||
| fn decl_class_ziparchive() -> Stmt { | ||
| class("ZipArchive") |
There was a problem hiding this comment.
ZIP classes lack shared contracts
The new ZipArchive declaration has no entry in catalog_classes.rs. CONTRIBUTING.md requires every supplied class to have a shared class contract, including classes declared by a prelude. Add ZipArchive and the new internal helper classes to that catalog before merging so their module and visibility information stays shared.
Context Used: AGENTS.md (source)
Prompt To Fix With AI
This is a comment left during a code review.
Path: src/zip_prelude/build.rs
Line: 622
Comment:
**ZIP classes lack shared contracts**
The new `ZipArchive` declaration has no entry in `catalog_classes.rs`. `CONTRIBUTING.md` requires every supplied class to have a shared class contract, including classes declared by a prelude. Add `ZipArchive` and the new internal helper classes to that catalog before merging so their module and visibility information stays shared.
**Context Used:** AGENTS.md ([source](https://github.com/illegalstudio/elephc/blob/main/AGENTS.md))
---
For each issue above, determine whether it is valid and should be fixed. If so, fix it directly.Note: If this suggestion doesn't match your team's coding style, reply to this and let me know. I'll remember it for next time!
9e04fc0 to
7f7a9fd
Compare
| emitter.label("__rt_sgmd_synth_generic"); | ||
| emit_set_str_const(emitter, "_meta_key_stream_type", 11, "_meta_stype_userspace", 10); | ||
| emit_set_str_const(emitter, "_meta_key_wrapper_type", 12, "_meta_wrapper_userspace", 10); | ||
| emit_set_str_const(emitter, "_meta_key_mode", 4, "_meta_mode_rb", 2); |
There was a problem hiding this comment.
Writable streams look read-only
The new generic wrapper branch always reports mode="rb", even when fopen() opened the wrapper with "w", "a", or "r+". The requested mode reaches stream_open() but is not saved for metadata, so callers checking the mode get the wrong answer. Save and return the actual mode on both AArch64 and x86_64.
Prompt To Fix With AI
This is a comment left during a code review.
Path: src/codegen_support/runtime/io/stream_get_meta_data.rs
Line: 85
Comment:
**Writable streams look read-only**
The new generic wrapper branch always reports `mode="rb"`, even when `fopen()` opened the wrapper with `"w"`, `"a"`, or `"r+"`. The requested mode reaches `stream_open()` but is not saved for metadata, so callers checking the mode get the wrong answer. Save and return the actual mode on both AArch64 and x86_64.
---
For each issue above, determine whether it is valid and should be fixed. If so, fix it directly.| // password may pass the header check on one build and fail on another. Either the read | ||
| // errors or it must not return the original plaintext. | ||
| if let Ok(data) = reopened.payload(0, 0) { | ||
| assert_ne!(data, b"legacy payload"); |
There was a problem hiding this comment.
Wrong-password test checks unrelated bytes
aes_encryption_requires_the_password() encrypts b"classified", but its wrong-password check compares returned bytes with b"legacy payload". If a wrong password returns the original plaintext, this test still passes. Compare with b"classified" so the assertion catches that failure.
Prompt To Fix With AI
This is a comment left during a code review.
Path: crates/elephc-zip/src/tests.rs
Line: 111
Comment:
**Wrong-password test checks unrelated bytes**
`aes_encryption_requires_the_password()` encrypts `b"classified"`, but its wrong-password check compares returned bytes with `b"legacy payload"`. If a wrong password returns the original plaintext, this test still passes. Compare with `b"classified"` so the assertion catches that failure.
---
For each issue above, determine whether it is valid and should be fixed. If so, fix it directly.7f7a9fd to
bb5e325
Compare
bb5e325 to
ba16736
Compare
| let data = archive.payload(index, 0)?; | ||
| fs::write(&target, data).map_err(|_| ZipError::Write)?; |
There was a problem hiding this comment.
Corrupt extractions report success
When an entry fails its CRC check, extractTo() still writes the returned bytes and reports success. It calls payload(), which drops the error flag from payload_stream(). A damaged archive can therefore leave a truncated or corrupt file without any failure signal. Use the CRC-preserving read here and return an error when the check fails.
Prompt To Fix With AI
This is a comment left during a code review.
Path: crates/elephc-zip/src/extract.rs
Line: 50-51
Comment:
**Corrupt extractions report success**
When an entry fails its CRC check, `extractTo()` still writes the returned bytes and reports success. It calls `payload()`, which drops the error flag from `payload_stream()`. A damaged archive can therefore leave a truncated or corrupt file without any failure signal. Use the CRC-preserving read here and return an error when the check fails.
---
For each issue above, determine whether it is valid and should be fixed. If so, fix it directly.ba16736 to
a326b96
Compare
| ("elephc_openssl", &["openssl-crypto"]), | ||
| // The archive bridge is a thin FFI layer over libzip; the catalog splices in | ||
| // its bzip2/xz/zlib/OpenSSL dependency chain. | ||
| ("elephc_zip", &["libzip"]), |
There was a problem hiding this comment.
Adding libzip here makes the release and nightly probes build it too. Those jobs still select the unchanged smoke22 image and do not prepare CMake. If that pinned image lacks CMake, a cold Linux probe fails with “cmake is required” and blocks publication. Adding CMake to the Dockerfile only affects future image builds. Publish and pin the updated image before adding this requirement.
Prompt To Fix With AI
This is a comment left during a code review.
Path: src/linker/native_packages.rs
Line: 40
Comment:
**ZIP blocks publication**
Adding `libzip` here makes the release and nightly probes build it too. Those jobs still select the unchanged `smoke22` image and do not prepare CMake. If that pinned image lacks CMake, a cold Linux probe fails with “cmake is required” and blocks publication. Adding CMake to the Dockerfile only affects future image builds. Publish and pin the updated image before adding this requirement.
---
For each issue above, determine whether it is valid and should be fixed. If so, fix it directly.c48a1ea to
3995f5d
Compare
Replace the pure-Rust archive engine with an FFI bridge over libzip 1.11.4 and the catalog's bzip2, XZ, zlib and OpenSSL packages. Migrate the PHP 8.5.10 ext/zip corpus, add the ZipArchive/zip_* prelude and the zip:// stream wrapper, expose --with-zip, and wire the bridge through the native package table, codegen harness, CI workflows and docs.
3995f5d to
87aec33
Compare
Summary
Adds PHP
ext/zipsupport as a thin FFI layer over libzip 1.11.4, the same C library PHP itself uses. The managed native catalog provideslibzip(with bzip2, XZ/LZMA, zlib, and OpenSSL), andelephc native add libzipinstalls the whole chain from verified sources. There is no system-lzip,-lbz2,-llzma, or-lcryptofallback.ZipArchiveand the deprecated proceduralzip_*API, built as AST declarations insrc/zip_prelude/build.rsand verified structurally againsttests/php_src/zip/prelude.phpby the synthetic-class oracle.zip://andgetStream*()user-space wrappers with PHP-shaped stream metadata, stream-context passwords, CRC-error reporting, read-mode enforcement, and archive-close invalidation.libzip1.11.4,bzip21.0.8,xz5.8.1. The resolver topologically orders managed archives so a program combining zip with curl/OpenSSL keeps every shared zlib/OpenSSL archive behind all of its dependents (GNU ld–safe).--with-zip, linker bridge, autoload probe, CI/nightly/release packaging, docs (docs/php/zip.md), andexamples/zip/with its committedelephc.toml/elephc.lock.scripts/ci/ensure_cmake.sh) and passes its directory to every container step throughELEPHC_CI_EXTRA_PATH, so producer and consumer toolchain fingerprints agree. The Alpine test images include CMake.The branch is one commit on current
main(d430f58367), final head87aec3320f, including theelephc-chopperparser move, theelephc buildCLI, theuribridge, and the recent checker/autoload/opcache changes.Reviews and corrections
Three complete Ollama reviews (GLM 5.3-flash, MiniMax M3.1-flash, Mistral Large 4) drove the final correction passes. Valid findings fixed include:
object-typed receiver fallthrough so method results are not silently coerced toInt(regression test added).addFile()now overwrites by default;extractTo()keeps php-src's positional selection semantics;getComment*returns""for entries without comments;zip_entry_read()normalizes non-positive lengths;zip_entry_compressionmethod()follows php-src's method table;close()clears detached state and releases cancelled handles.zip://rejects write modes (r/rb/r+accepted), reports CRC errors, matches wrapper schemes case-insensitively, and enforcesopen_basedirinopen()/addFile()/replaceFile()/extractTo().AT_FDCWDis per-OS, soextractTo()restores mtimes on macOS/iOS as well as Linux (covered by a test).add_or_replace_filevalidates names before creating sources;elephc-ziptests are non-flaky; temporary fixture parents are removed; the prelude emits zeroUnused variablewarnings; stray scratch files were removed; release packaging buildslibelephc_zip.a; OpenSSL recipe revisions were bumped for the iOSno-asmchange; staticlib CMake identities are documented.getFromName()andextractTo()(only stream reads warn), extracts nothing for associative selection keys (only integer keys are read), throws forgetExternalAttributesName(''), and omitswrapper_typeforgetStream*metadata; the bridge matches those results except thatextractTo()now refuses the corrupt output.A final Greptile pass found additional valid issues, corrected here:
extractTo()refuses a final-component symlink (O_NOFOLLOW) and verifies the canonical parent stays inside the destination; archived permission bits are ignored, so a setuid/setgid entry cannot install a privileged file. The existing../absolute-name sanitization remains.getStream*()call gets its own position;stream_stat()reports the entry size; closing an archive clears its snapshots;close()invalidates streams on cancellation and callback-throw paths.stream_get_meta_data()copies the URI into owned storage and reports the actualfopen()mode, so saving metadata survives handle-slot reuse and writable wrappers no longer report"rb".addPattern()accepts trailing modifiers (/...$/i) while still emitting PHP's "No ending delimiter" warning;addGlob()/addPattern()return failure when compression or encryption cannot be applied./, no component..) is shared byopen(),addFile(),replaceFile(),extractTo(),addGlob(), andaddPattern().zip_*functions have sharedPreludeProvidedcontracts,ZipArchiveand its internal helpers have class contracts, andzip_close()/zip_entry_close()release their temporary resources.setEncryptionName(..., null)uses the archive default password; removing an archive comment clears$zip->comment; a subclassgetStream*override keeps its declared return type.file_get_contents()closes its hidden wrapper descriptor whenstream_read()/stream_eof()throws, so caught failures cannot exhaust the 256 handle slots.close()writes, so deadline-based cancellation stops a large archive. The observable0.0/1.0progress endpoints remain PHP-side.extractTo()rejects a CRC-corrupt entry instead of installing its decoded bytes, a deliberate safety divergence from php-src 8.5.10.ELEPHC_CMAKEpath so native toolchain fingerprints match and libzip can find CMake. The iOS curl-link probe now reads the OpenSSL r2 artifacts instead of r1.Verification
cargo build— clean apart from the pre-existing workspace manifest/build-script warnings.cargo test --test codegen_tests_ext 'codegen::zip::'— 39 passed (including the new subclass, default-password, comment, corrupt-extraction, progress, cancel, and addGlob error cases).cargo test --test codegen_tests_ext 'codegen::zip_php_src::'— 109 passed.cargo test -p elephc-zipwithELEPHC_ZIP_NATIVE_LIB_DIRS— 11 passed (including symlink and privileged-mode extraction).cargo test -p elephc --lib native_deps— 129 passed;zip— 10;prelude_probe— 12; the zip prelude AST oracle passes.cargo test --test codegen_tests_oop test_object_typed_receiver_keeps_method_return_type— passes.python3 -B -m unittest discover -s scripts/ci -p 'test_*.py'— 149 passed;test_variant_configneeds Python ≥3.11 fortomllib, so the local Python 3.9 run reports only that import error.codegen::io::streams::test_stream_get_meta_data_wrapper_keeps_uri_and_modeandtest_file_get_contents_wrapper_read_throw_releases_handle— pass.audit_builtins, site compatibility, EIR boundary) pass; workflows and composite actions parse.elephc build examples/zip/main.php && ./examples/zip/main— writes, reads, comments, extracts, and streams through real libzip; a zip build emits zeroUnused variablewarnings.--with-curl --with-zipprogram links both chains and runs; CI's managed-native smoke exercises the same combination on Linux.3995f5d118— green: Linux and macOS codegen/non-codegen shards, managed-native smokes (libzip plus curl/zip link order), and builtins-docs sync.php-src fixtures
The committed corpus is the PHP 8.5.10
ext/zip/testssuite (112 fixtures): 109 generated inline tests pass on macOS,oo_addfile_procis Linux-only,bug51353carries an unconditional php-src SKIPIF, andgh17319expects false from PHP's own freed archive resource. Compiler-compatibility source rewrites are listed intests/php_src/zip/README.md.Supported targets
The bridge and native recipes cover
macos-aarch64,ios-arm64,ios-sim-arm64,linux-aarch64, andlinux-x86_64. The managed-native smoke builds libzip and its chain for both iOS targets; Linux executable coverage is supplied by the codegen shards and the curl+zip smoke.Remaining documented differences
See
docs/php/zip.md: user-spacezip://(eager entry read,fread()-prefixed CRC warning),getStream*()snapshot/seekable metadata,addPatternbyte semantics/delimiters/xmode,addGloboption validation andGLOB_*coverage, non-UTF-8 and interior-NUL names, stricter..extraction sanitization, customextractTostream wrappers, one-active-context model, the 72 KiB unconditional zip stream metadata tables, separate OpenSSL 3.5.8/3.6.4 static builds when zip and cipher are combined, intermediate progress-callback throws being swallowed by the bridge wrapper, and CMake not being part of the libzip artifact identity.extractTo()intentionally rejects CRC-corrupt payloads instead of installing them.No
CHANGELOG.mdentry is included, per the repository's release-management policy.