-
Notifications
You must be signed in to change notification settings - Fork 268
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
v1 WordPress Boot Protocol #1390
Merged
Merged
Conversation
This file contains 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
adamziel
added
[Type] Enhancement
New feature or request
[Package][@wp-playground] WordPress
[Feature] Boot Flow
labels
May 14, 2024
adamziel
changed the title
WordPress Boot Protocol
Explorations: WordPress Boot Protocol
May 15, 2024
bgrgicak
reviewed
May 16, 2024
I really like the direction of this PR. It will at least make it much easier to understand how Playground is booting. |
adamziel
force-pushed
the
playground-boot-protocol
branch
from
May 20, 2024 22:52
0ef6ea0
to
ce3e9e5
Compare
…PlatformLevelMuPlugins
adamziel
changed the title
Explorations: WordPress Boot Protocol
WordPress Boot Protocol
May 23, 2024
There are follow-up tasks, but there's a clear value add already so I'm going to merge this as it is. Let's keep iterating. (the unit test failures are intermittent) |
adamziel
added a commit
that referenced
this pull request
May 29, 2024
## What is this PR doing? Ships a `DirectoryHandleMount` class that can be used to mount OPFS using the `php.mount()` method: ```ts await php.mount( php.documentRoot, createDirectoryHandleMountHandler(opfsHandle); ); ``` ### Other changes This PR removes the `Mountable` interface in favor of functional API to simplify the implementation and remove any state management concerns. **Before:** ```ts php.mount(dir, new NodeFSMount(dir)); ``` **After:** ```ts php.mount(dir, createNodeFsMountHandler(dir)); ``` ## What problem is it solving? It enables mounting OPFS and local directory handles in the browser version of Playground using the same abstraction as we use for mounting local directories in Node.js. This, in turn, enables using OPFS mounts in the [boot protocol](#1390) and relying on the same general code paths and abstractions. ## How is the problem addressed? DirectoryHandleMount is not a "real" mount in that it doesn't actually plug in an Emscripten FS implementation into the PHP Emscripten module. Instead, it copies all the OPFS files into Playground MEMFS (or the other way around). After that initial sync, it journals all the MEMFS filesystem operations and replays them in OPFS. This is good enough for the in-browser directory handle, since the underlying files aren't going to change on their own, but for the Local Filesystem directory handle we also have an explicit "Synchronize files" button to bring any local changes back into Playground. Once Emscripten supports asynchronous filesystem operations via wasmfs, we'll be about to get rid of the journal and mount an OPFS implementation to directly delegate writes, reads, etc to the underlying filesystem. ## Testing Instructions Open local Playground and change the storage option to "browser", make some visible changes, refresh Playground a few times, confirm the site still loads and the changes are still around. Close the browser, reopen it, confirm it still works. Them repeat the test with the local directory storage option. Also, confirm the following Playground CLI command works and sets up a site in a local `new-wordpress-site` directory: ```bash bun packages/playground/cli/src/cli.ts server --mount-before-install=`pwd`/new-wordpress-site:/wordpress ```
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Labels
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 is this PR doing?
Implements a
bootWordPress()
function aiming to provide a reliable and consistent boot pipeline for every Playground-based app, whether it's a browser app, server app, a VS Code extension, or anything else.As a nice side-effect, Playground can now boot not just from the custom minified WordPress builds, but also from the official WordPress releases!
Related issue: #1398
How does it work?
bootWordPress()
ties together all the pieces from different Playground-based apps. Boot flow diagram demonstrates the idea. A tl;dr pipeline is:Here's a usage example in a Node.js app:
Testing instructions
http://localhost:5400/website-server/?php=8.0&wp=http://localhost:5400/plugin-proxy.php?url=https://wordpress.org/nightly-builds/wordpress-latest.zip
Follow-up work
setupPlatformLevelMuPlugins()
in unit tests withbootWordPress()
BootOptions
and confirm PHP.ini directives are used, constants are created etc.createPhpInstance()
argument in favor of using just thePHP
class – once Breaking: PHP: Remove NodePHP and WebPHP classes in favor of a single "PHP" class #1457 mergesdebug.log
in theconfigureErrorLogging
mu-plugin – right now it's stored in/wordpress/wp-content
custom
where Playground relies ondb.php
brought in fromcc @brandonpayton @bgrgicak