Skip to content

feat(opcache): relocate intersection/union type lists in cache binaries - #256

Merged
lisachenko merged 1 commit into
8.4from
claude/opcache-112-relocate-type-lists
Aug 19, 2026
Merged

feat(opcache): relocate intersection/union type lists in cache binaries#256
lisachenko merged 1 commit into
8.4from
claude/opcache-112-relocate-type-lists

Conversation

@lisachenko

Copy link
Copy Markdown
Owner

What this changes

Fixes #112 — first of a five-PR stacked chain widening PayloadRelocator payload coverage (#112#114#115#116#113; merge in order, GitHub retargets each next PR automatically).

Ports the ZEND_TYPE_HAS_LIST branch of zend_file_cache_(un)serialize_type from php-src 8.4: zend_type_list pointer relocation plus recursion into every zend_type entry (the ZEND_TYPE_LIST_FOREACH walk), both directions, keeping the C SERIALIZE_PTR/UNSERIALIZE_PTR walk-through-real-address pattern. New unserializeTypeStruct/serializeTypeStruct in src/OpCache/PayloadRelocator.php; the unsupportedPayload('intersection/union type-list relocation') refusals are gone. Acceptance per the issue: fixture with union param/return, intersection param+return, union property and DNF property (A&B)|C|null round-trips byte-for-byte and executes from the patched cache (TypeListRelocationTest: round trip, resave-executes, size-changing string patch executes). docs/opcache-binary.md scope updated.

Environment it was verified on

  • PHP version (full first line of php -v): PHP 8.4.19 (cli) (built: Mar 30 2026 19:28:35) (NTS)
  • Thread safety: NTS
  • OS / architecture: Linux x86-64 (Ubuntu)
  • Debug build (--enable-debug)? yes — debug 8.4 container --group opcache --fail-on-skipped green at this point of the chain (34 tests)

Also (verified per-issue before each commit): full default suite baseline-identical; --group opcache --fail-on-skipped green on release + debug; PHPStan level max clean; cs-fixer clean. Chain-final numbers on the #113 head: default suite 519 tests, opcache gate 47 tests, opcache-runner mode no new skips.

Checklist

  • Targets the minimum affected version branch (8.4) — fixes cascade upward, never downward
  • composer test passes on the matching PHP minor
  • composer phpstan (level max) and composer cs:check are green
  • Tests added or updated; all struct fields used (zend_type_list et al.) already in the generated defs
  • tools/generator/symbols.php unchanged — nothing under include/, stubs/ or .phpstorm.meta.php touched
  • Conventional Commits used for the commit messages

🤖 Generated with Claude Code

https://claude.ai/code/session_01BDcCQiYqbMkjRPyhWgLL6M


Generated by Claude Code

…he payload

Port the ZEND_TYPE_HAS_LIST branch of zend_file_cache_serialize_type /
zend_file_cache_unserialize_type (ext/opcache/zend_file_cache.c, PHP-8.4.19):
the zend_type_list pointer is relocated (SERIALIZE_PTR keeps walking through
the still-real address, exactly like the C serialize/unserialize pair) and the
walk recurses into every zend_type entry, so DNF sub-lists like (A&B)|C unfold
naturally. The unsupportedPayload refusal for type lists is gone in both
directions.

New fixture tests/OpCache/fixtures/type-lists.php exercises a union parameter,
a union return type, an intersection parameter and return type, and union/DNF
property types (the DNF one nests an intersection list inside a union list).

Acceptance evidence:
- TypeListRelocationTest::testTypeListPayloadRoundTripsByteIdentical - the
  compiled fixture relocates and derelocates byte-for-byte
- testUnmodifiedResaveStillExecutes / testPatchedTypeListFixtureExecutesFromCache
  - the re-serialized (and string-literal-patched) binary is executed by a
  fresh worker straight from the cache
- full default suite, --group opcache --fail-on-skipped, phpstan level max and
  php-cs-fixer all green on PHP 8.4.19 NTS

Fixes #112

Co-Authored-By: Claude <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01BDcCQiYqbMkjRPyhWgLL6M
@lisachenko
lisachenko force-pushed the claude/opcache-112-relocate-type-lists branch from 0ca07da to 79f7cbe Compare August 19, 2026 21:59
@lisachenko
lisachenko marked this pull request as ready for review August 19, 2026 22:37
@lisachenko
lisachenko merged commit 35c901d into 8.4 Aug 19, 2026
21 checks passed
@lisachenko
lisachenko deleted the claude/opcache-112-relocate-type-lists branch August 19, 2026 22:40
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

feat(opcache): relocate intersection/union type lists in cache binaries

2 participants