Skip to content

[PHP.wasm] Export filesystem symbols for PHP side modules#3643

Merged
adamziel merged 1 commit into
trunkfrom
adamziel/export-side-module-fs-symbols
May 14, 2026
Merged

[PHP.wasm] Export filesystem symbols for PHP side modules#3643
adamziel merged 1 commit into
trunkfrom
adamziel/export-side-module-fs-symbols

Conversation

@adamziel
Copy link
Copy Markdown
Collaborator

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:

  • closedir
  • fseek
  • ftell
  • isalnum
  • mkdir
  • opendir
  • readdir
  • rename
  • rmdir
  • unlink

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:

TypeError: resolved is not a function

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-editor

Then 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.html

The 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.

Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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
@adamziel adamziel changed the title Export filesystem symbols for PHP side modules [PHP.wasm] Export filesystem symbols for PHP side modules May 14, 2026
@adamziel adamziel merged commit 1b332e0 into trunk May 14, 2026
53 checks passed
@adamziel adamziel deleted the adamziel/export-side-module-fs-symbols branch May 14, 2026 22:51
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants