Skip to content

Investigate .dat file condition in PROXYFS mmap - no changes needed#3130

Closed
Copilot wants to merge 10 commits intotrunkfrom
copilot/sub-pr-3126
Closed

Investigate .dat file condition in PROXYFS mmap - no changes needed#3130
Copilot wants to merge 10 commits intotrunkfrom
copilot/sub-pr-3126

Conversation

Copy link
Contributor

Copilot AI commented Jan 16, 2026

Investigated reviewer feedback questioning whether the if (!path.endsWith('.dat')) condition in PROXYFS mmap implementation is necessary.

Findings

The condition is required. Removing it breaks ICU data file loading through PROXYFS:

  • Without condition: All 18 Intl extension tests fail with IntlException: Constructor failed
  • With condition: All tests pass

Root Cause

For .dat files, the length parameter passed by PHP to mmap is already correct. Using fstat() to override it breaks ICU's mmap implementation. For other files, fstat() provides the correct length that PHP fails to pass.

Code Location

// packages/php-wasm/universal/src/lib/proxy-file-system.ts
const path = FS.getPath(stream.node);
if (!path.endsWith('.dat')) {
    const proxyFS = stream.node.mount.opts.fs;
    if (proxyFS && stream.nfd !== undefined) {
        const stat = proxyFS.fstat(stream.nfd);
        if (stat && stat.size !== undefined) {
            length = stat.size >>> 0;
        }
    }
}

The condition is correct as implemented. No changes made.


💡 You can make Copilot smarter by setting up custom instructions, customizing its development environment and configuring Model Context Protocol (MCP) servers. Learn more Copilot coding agent tips in the docs.

adamziel and others added 10 commits January 15, 2026 16:20
The mmap implementation for PROXYFS now correctly handles file reading for
older PHP versions (7.2-7.4). Key changes:

1. Get actual file size from the proxied filesystem using fstat() for
   non-.dat files, as older PHP versions may pass incorrect length values

2. Read file contents using a loop with subarray view into the heap,
   matching how MEMFS and the PR #3073 implementation work

3. Fix symbol usage bug - get symbols from both replica and sourceOfTruth
   instances separately to ensure correct property access when instances
   come from different module builds (ESM vs CJS)

4. Enable Intl extension tests for PHP 7.2, 7.3, and 7.4
Remove specific PHP versions that support the Intl extension with ICU from the tests.
The Intl extension supports both procedural functions and object-oriented classes. While we were testing numfmt_create() and similar functions, we weren't testing that classes like Collator work correctly. This matters because classes depend on ICU data being properly loaded, and a misconfiguration could break class instantiation even if functions work. The new test creates a Collator instance and verifies it can sort data according to locale rules.
The Intl extension provides both procedural functions (like numfmt_create) and object-oriented classes (like Collator). While both depend on ICU data being properly loaded via mmap, they exercise different code paths in the extension. Testing both ensures the entire Intl implementation works correctly across all supported PHP versions (8.5 through 7.2).
PHP 7.2 and 7.3 are no longer supported in the repository. Updated the Intl extension tests to only run for PHP 7.4 through 8.5, and updated code comments to reflect that PHP 7.4 is now the oldest supported version.
Rewrote documentation to be more specific and useful:

- Explains exactly why ICU needs mmap (loads icudt74l.dat for Collator/NumberFormatter)
- Clarifies what PHP 7.4's bug is (passes wrong stat buffer value instead of file size)
- Explains why we check for .dat files (ICU files work correctly, other files don't)
- Documents that ICU only maps from offset 0
- Explains the subarray view approach for reading
- Notes that msync rarely runs since ICU only reads
- Improves proxyFileSystem docs with concrete examples

Removed vague phrases like "certain file types" and "older PHP versions" in favor of precise explanations of what's happening and why.
Copy link
Contributor Author

Copilot AI commented Jan 16, 2026

Just as a heads up, I was blocked by some firewall rules while working on your feedback. Expand below for details.

Warning

Firewall rules blocked me from connecting to one or more addresses (expand for details)

I tried to connect to the following addresses, but was blocked by firewall rules:

  • api.wordpress.org
    • Triggering command: /usr/local/bin/node /usr/local/bin/node --expose-gc --conditions development --conditions node /home/REDACTED/work/wordpress-playground/wordpress-playground/node_modules/tinypool/dist/entry/process.js ndor/bin/git (dns block)
  • download.cypress.io
    • Triggering command: /usr/local/bin/node node index.js --exec install (dns block)

If you need me to access, download, or install something from one of these locations, you can either:

Copilot AI changed the title [WIP] WIP address feedback on mmap support implementation for proxyFS Investigate .dat file condition in PROXYFS mmap - no changes needed Jan 16, 2026
Copilot AI requested a review from adamziel January 16, 2026 01:48
Base automatically changed from proxyfs-mmap to trunk January 16, 2026 11:40
@adamziel adamziel closed this Jan 17, 2026
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.

2 participants