[PHP.wasm] Export filesystem symbols for PHP side modules#3643
Merged
Conversation
Contributor
There was a problem hiding this comment.
Pull request overview
Note
Copilot was unable to run its full agentic suite in this review.
Adds POSIX filesystem/libc symbols to the PHP exported-functions list so PHP.wasm side modules can resolve them at runtime, preventing lazy "resolved is not a function" failures.
Changes:
- Adds 10 filesystem/libc symbols (closedir, fseek, ftell, isalnum, mkdir, opendir, readdir, rename, rmdir, unlink) to the canonical exported-functions list.
- (Per PR description) Regenerates Node PHP artifacts for 5.2, 7.4, 8.0–8.5 in both asyncify and JSPI modes.
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
Comment on lines
17
to
+19
| _sqlite3_auto_extension | ||
| _sqlite3_cancel_auto_extension | ||
| _unlink |
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.
What
Exports filesystem/libc symbols used by PHP.wasm side modules from the Node PHP artifacts, and adds them to the canonical PHP exported-functions list for future builds.
This extends the earlier SQLite auto-extension exports with the POSIX helpers needed by side modules that read and write mounted files:
The checked-in Node PHP artifacts for PHP 5.2, 7.4, and 8.0-8.5 were updated for both asyncify and JSPI modes. The web artifacts already exported the target symbols where present.
Why
A PHP side module can load successfully but still fail lazily at runtime when it first calls a filesystem helper that the main PHP wasm module does not export. The observed failure was:
Debugging showed the unresolved dynamic symbol was
opendir, called when a SQLite virtual table extension scanned a mounted Markdown directory.Local verification
Verified against a local Playground checkout from this branch using a PHP 8.4 JSPI side module mounted into WordPress:
PATH=/Users/cloudnik/.local/share/nvm/v24.14.0/bin:$PATH \ npx nx dev playground-cli server \ --php=8.4 \ --port=9418 \ --login \ --php-extension=/Users/cloudnik/conductor/workspaces/wp-extensions/tunis-v1/markdown-editor/sqlite-markdown-extension/dist/manifest.json \ --mount-dir /Users/cloudnik/conductor/workspaces/wp-extensions/tunis-v1/content /markdown-root \ --mount-dir /Users/cloudnik/conductor/workspaces/wp-extensions/tunis-v1/markdown-editor /wordpress/wp-content/mu-plugins \ --mount-dir /Users/cloudnik/conductor/workspaces/wp-extensions/tunis-v1/markdown-editor /internal/shared/markdown-editorThen requested:
curl -fsSL -c /tmp/wp-md-cookies.txt -b /tmp/wp-md-cookies.txt \ http://127.0.0.1:9418/wp-admin/edit.php?post_type=page \ -o /tmp/markdown-editor-local-final.htmlThe response completed successfully and grep found no
TypeError,resolved is not a function, unresolved wasm symbol, PHP warning, or WordPress database error.Also verified all checked-in PHP wasm artifacts export each target symbol wherever the function exists.