Skip to content

[PHP.wasm] Fix sqlite_markdown extension loading - #3650

Merged
adamziel merged 3 commits into
trunkfrom
adamziel/fix-sqlite-markdown-extension
May 16, 2026
Merged

[PHP.wasm] Fix sqlite_markdown extension loading#3650
adamziel merged 3 commits into
trunkfrom
adamziel/fix-sqlite-markdown-extension

Conversation

@adamziel

@adamziel adamziel commented May 16, 2026

Copy link
Copy Markdown
Collaborator

What it does

Fixes the web runtime crash when loading the published sqlite_markdown
extension manifest in JSPI PHP builds.

Click here to test on Playground

Rationale

The deployed web PHP 8.4 JSPI build does not export every symbol imported by
the sqlite_markdown side module. Emscripten wires those missing imports as JS
stubs, and the browser later crashes with TypeError: n is not a function
during extension startup. The same export list is shared by the other PHP
versions, so this rebuild carries the fix across the JSPI matrix.

Implementation

Adds _strtoll and _php_info_print_table_header to the PHP export list and
rebuilds the web JSPI artifacts for PHP 7.4 through 8.5. The rebuilt modules
also pick up the existing SQLite/filesystem exports already listed for side
modules, including _sqlite3_auto_extension,
_sqlite3_cancel_auto_extension, _opendir, _readdir, _mkdir, _rename,
and _unlink.

This does not try to make Asyncify side-module loading work. PHP 8.5
Asyncify is rebuilt only as a generated-runtime canary so CI keeps exercising
one Asyncify artifact after the export-list change.

Adds a browser e2e regression that loads the real published manifest URL
pinned to 4656cd898cf8430c44e985d0515c2182ffcc5575,
creates a markdown file in the PHP filesystem, and queries the extension's
markdown_posts and markdown_postmeta SQLite virtual tables.

Testing instructions

PATH="/usr/local/opt/node@22/bin:$PATH" NX_DAEMON=false npx nx e2e php-wasm-web -- --grep "External PHP side modules" --workers=1 --project=chromium --reporter=list

Verified that all rebuilt JSPI artifacts, plus the PHP 8.5 Asyncify canary,
export strtoll and php_info_print_table_header.

Also manually verified the original URL locally through npm run dev. It
booted to /wp-admin/edit.php?post_type=page, showed the markdown editor admin
notice, and listed the markdown-backed pages.

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

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.

Fixes a PHP 8.4 web runtime crash when loading the published sqlite_markdown extension manifest by exporting the missing _strtoll and _php_info_print_table_header symbols and rebuilding the JSPI artifact. Also adds an e2e regression test.

Changes:

  • Add _strtoll and _php_info_print_table_header to the PHP exported functions list.
  • Rebuild PHP 8.4 JSPI web artifact (8.4.20 → 8.4.21) picking up newly exported symbols.
  • Add a Playwright e2e test that loads the real published sqlite_markdown manifest and queries its virtual tables.

Reviewed changes

Copilot reviewed 3 out of 4 changed files in this pull request and generated 3 comments.

File Description
packages/php-wasm/compile/php/exported-functions.list Adds _strtoll and _php_info_print_table_header to exported symbols.
packages/php-wasm/web-builds/8-4/jspi/php_8_4.js Regenerated runtime exposing new exports and bumping to 8.4.21.
packages/php-wasm/web/src/test/php-dynamic-loading.spec.ts New e2e test verifying the published sqlite_markdown extension loads and works.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread packages/php-wasm/web/src/test/php-dynamic-loading.spec.ts
Comment thread packages/php-wasm/web/src/test/php-dynamic-loading.spec.ts
Comment thread packages/php-wasm/compile/php/exported-functions.list Outdated
@adamziel
adamziel merged commit 214760f into trunk May 16, 2026
53 checks passed
@adamziel
adamziel deleted the adamziel/fix-sqlite-markdown-extension branch May 16, 2026 14:32
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment