Replies: 15 comments 48 replies
-
cc @wojtekn @fluiddot @sejas @p-jackson for any wp-now/Studio insights. |
Beta Was this translation helpful? Give feedback.
-
Perhaps BrowserFs could solve some of the problems here - it seems to support „overlaying” filesystem layers on top of each other, meaning we could perhaps use a local WordPress directory and add a custom db.php in VFS without affecting the user’s project. Another idea would be to use linux mount:
|
Beta Was this translation helpful? Give feedback.
-
I think that we should allow for two options. Either you give Playground a location and let it add files as needed. Or you give it a populated directory with WordPress. For example Playground web provides a WordPress directory, but only partially. |
Beta Was this translation helpful? Give feedback.
-
I would copy what Docker does here. Mounting would result in a sync between directories. We could also offer copy as a option for cases where you don't want to modify your local mount point. |
Beta Was this translation helpful? Give feedback.
-
This should be handled by the developer the same way wp-now does it now. |
Beta Was this translation helpful? Give feedback.
-
Imported files should override runtime-provided files. This will give developers control. |
Beta Was this translation helpful? Give feedback.
-
This could be a nice way to ensure we always run the latest version.
We could detect if the SQLite plugin is mounted in wp-content/plugins and not load the internal plugin if it exists. |
Beta Was this translation helpful? Give feedback.
-
I would always include the entire directory. This is what Playground needs to run and it gives users control over what version to use.
I wouldn't include internals. These files are part of Playground and may depend on the current version of Playground. |
Beta Was this translation helpful? Give feedback.
-
I see two different parts to this discussion. One is how Core Playground works, this is the unopinionated system that allows us to build modules like Playground Web and Server.
It always expects a fully populated VFS. If a file is overridden or excluded. Playground might break, it won't try to resolve the issue internally.
They accept user input like mount points. They may include some complex logic to stitch the VFS together, pull data from various sources, and handle conflicts. |
Beta Was this translation helpful? Give feedback.
-
Full snapshotsA full snapshot freezing the entire site in time would include a top-level Partial snapshotsA minimal snapshot relying on the runtime and network resources for setup could ship just a single mu-plugin or a CSS file. However, there's no reliable way of handling a zip archive with just a single file inside. We need a path mapping. The path mapping could be implicit, meaning the zip archive would have a Consider snapshot A with a Or consider snapshot B with a Supporting partial snapshots requires shipping additional metadata to inform the import process. Partial snapshot metadataI'm not yet sure what that metadata should be, but I'm thinking about supporting:
Perhaps that's too much for v1, though, and supporting just |
Beta Was this translation helpful? Give feedback.
-
Noodling on the discussion, I came up with this boot flow that we could implement without any new platform-level features – I'd love to learn what you think. Is there any use-case this wouldn't handle? My impression is that this would work pretty well for all the discussed use-cases. I'd still like to map them out separately to be extra sure, e.g. importing from GitHub, mounting OPFS in the browser, multiple local mounts in Node.js, pre-mounting This flow would still affect Conflicting or outdated |
Beta Was this translation helpful? Give feedback.
-
This is a response to the original post. I haven't reviewed the latest comments yet. Some overall thoughts: It would be good favor an explicit language of configuration over magic that makes specific scenarios easy but might not dovetail well with all uses of the system. Maybe it would make sense to have some kind of "setup compiler" that takes explicit declarations about FS and DB and yields a usable WordPress setup (comprised of FS, DB, etc). There would also be a validation step that confirms the result looks like a complete WordPress setup. Something like Compile -> Validate -> Boot. Instead of having questions about how different FS combinations should work, why don't we turn those questions into explicit config options for FS construction? The same could go for questions about DB construction. The main idea is: Compilation of setupAn FS config would be comprised of an arbitrary number of declarations about the filesystem, including identifying specific paths, whether and how to populate files for those paths, and whether each path should be read-only or writable. The result would be a single directory tree. A DB config would be comprised of a declaration of type. The type could be SQLite, MySQL, or custom, where "custom" means the user will rely on what is set up in the FS. The "custom" option could even be used when providing user-provided versions of things like sqlite-database-integration. This is kind of like a platform blueprint where today's blueprints are more like "runtime" blueprints in comparison. As @bgrgicak mentioned
Making setup explicit doesn't mean that the UX for Playground needs to overwhelm the user with options. There could be sensible defaults and thoughtful config options, but with explicit setup compilation, a platform language would be there for deeper cases, less common cases, and unanticipated cases. |
Beta Was this translation helpful? Give feedback.
-
With explicit declaration, this question would be answered by the user.
Perhaps this could be part an explicit declaration as well, with more format types supported over time. Validate that FS and DB config matches expected WP format. If validation fails, we might continue loading Playground but validation errors could be listed in the event a crash or failure to load WordPress.
Users should be explicit about what they want here. But could we have sensible defaults that minimize friction, surprises, and the need juggle a bunch of things in one's head? Are there ways we could store different WP versions and builds by key so they don't conflict, and we can mount the one desired?
All decisions should be made as part of initial config. If we are talking about default Playground UI experience on the web, we need to design so that no surprise conflicts are possible. If we are letting a user mutate WP state, we need to make sure conflicts are impossible. QUESTION: What kinds of conflicts are possible today? NOTE: I don't yet know how playground.internal is used but will find out.
Maybe /internal is a good place? Or /data?
This needs to be configured explicitly. And perhaps the default is that it is always installed unless the configuration says otherwise.
IMO it is clearer and cleaner to keep platform mu-plugins separate from user mu-plugins.
This should be declared explicitly.
Can we detect when running the installer is needed? This should be checked as part of pre-boot validation. Perhaps users should say whether they expect WP tables to exist already or whether they should be auto-created by Playground if missing.
I may not understand the context, but naively... Could we mount as read-only or copy the files into temporary storage?
Read-only sources should be the default. Writability should be explicitly configured as part of setup.
Conceptually, I don't think this is a Playground use case. Or if it is, it should be related with according to Site Transfer Protocol.
This sounds the same as (or similar to) a "WordPress setup" compiler.
Everything necessary to run the configuration in Playground, even if some elements are merely references to external resources.
What kinds of changes?
It feels like we might want two kinds of exports:
The casual export should be lighter and work most of the time, but if someone wants an exact copy of the setup, it would be good to be able to have something like an "archival" export. It would be helpful for stability and bug repro to export exact software for a given Playground session.
At first, this seems like an easy "yes", but what if others' blueprints contain actual secrets they will later use in production?
Perhaps each export should have two files: an export zip and a separate sibling metadata file. That way the information is available but harder to accidentally leak to others
I think we would want Playground to be able to apply sensible defaults, as long as Playground doesn't modify the actual snapshot in-place.
This seems to be a place for separate-but-complementary tooling. Or maybe it is a different kind of export. |
Beta Was this translation helpful? Give feedback.
-
I summarized some points in a new Boot protocol issue – thank you so much for all your great thoughts! |
Beta Was this translation helpful? Give feedback.
-
Actually I'm reopening the discussion. Here's one more conundrum to solve: In Playground docs workflow I have multiple Blueprints:
I wonder how could we reduce duplication between the web Blueprint and the development Blueprint. Unzipping an external zip is a part of a Blueprint, but mounting a local directory isn't. However, these operations correspond to each other. Also, with a "copy instead of mounting" feature, both could be expressed as Boot options, not Blueprint steps. I wonder:
Perhaps Blueprints could have a runtime-specific list of resources where runtime is web, CLI etc. Or maybe an "environment", e.g. "preview", "develop", "test" etc. would be a better abstraction? Something like this: {
"environments": {
"preview": {
"resources": {
"gutenberg": { "resource": "wp.org/plugins", "slug": "gutenberg" }
}
},
"develop": {
"resources": {
"gutenberg": { "resource": "local-mount", "path": "./gutenberg" }
}
}
},
"pathMapping": {
"/wordpress/wp-content/plugins/gutenberg": "gutenberg"
}
} |
Beta Was this translation helpful? Give feedback.
-
All Playground apps need a consistent boot/export protocol. They don't have one yet. Playground.wordpress.net, Playground CLI, wp-now, Studio -- they all boot in their own way, creating inconsistencies and maintenance hurdles. Let's define a consistent boot/export protocol that Playground tools will be able to reuse.
What is a Boot/Export protocol?
There are two parts:
While there is an overlap with the Site Transfer protocol, this is a Playground-specific discussion.
Technical assumptions
/wordpress
and/tmp
and/internal
directories in place. That's the case even in Node.js. We may eventually build tools that operate on the host filesystem directly -- they're out of scope for now as most of the problems outlined here just don't apply there.Discussion goals
Building VFS
Building VFS is the first boot stage. Once it's finished, we have the correct WordPress file structure. WordPress itself may not be able to start yet, since the database may not be configured yet, but all the files sources are at least wired to their correct location in VFS.
Building VFS involves:
Decisions to make in the flow -- let's discuss these points:
wp-content/index.php
/wordpress
directory/wordpress
directory, hoping Playground will populate itwp-config.php
rewrites to pollutegit status
. We don't want the SQLitedb.php
to bleed out and get deployed to a repo containing a MySQL site.wp-config.php
may need rewriting, e.g. when aSITE_URL
constant is already defined there. We could display a warning.db.php
file must be created and we can't fake it./wordpress
sunrise.php
file could perhaps be faked as an mu-plugin.wp-content
, say a few plugins, uploads but not a theme. How could that be automatically wired together in a correct way in a higher-level tool? Use-case: not keeping thetwentytwentyfour
theme in a GitHub repo just to make Playground happy.OPFS
db.php
is present because Playground is used to develop a drop-indb.php
plugin.playground.internal
URLs be rewritten to the current server URL on boot in the imported files (not in the database)?Another visual to illustrate some of the challenges:
Out of scope for now:
Technical constraints:
auto_prepend_file
db.php
andsunrise.php
.sunrise.php
can maybe be avoided, but I don't think there's an easy way to avoid creatingdb.php
on the disk.Building the database
After this step, WordPress should be able to connect to the database and access the basic tables. In the 95% use-case it would already be a functional site. In 5% use-case, a custom "WordPress base snapshot" may rely on a Blueprint to finalize the setup and the site wouldn't work yet. In any case, the database connection and the required
wp_*
tables should now be in place.Decisions to make in the flow -- let's discuss these points:
db.php
file, if present, is related to SQLite?db.sqlite
file located?wp-content/mu-plugins
or in/internal
?db.php
ifwp-content
is mounted? (also decided in the Build VFS step)data.sql
file to executedb.sqlite
file but are supposed to use MySQL?playground.internal
URLs be rewritten in the imported data?playground.internal
URLs be rewritten in the existing database?wp_*
tables.Handle runtime changes
Running a Blueprint on a database-connected site may affect files in the mounted directories. Sometimes that's desired, sometimes it isn't.
Design conundrums -- let's discuss these points:
wp-content/plugins
, but not the others, e.g. never change mywp-config.php
?wordpress.zip
file a valid use-case? Or do will we always need an import tool to rewrite the site URL and, in general, apply the Site Transfer Protocol.Snapshot Export
Exporting Playgrounds is actually a part of the Boot process. Why? Because people will want to run those exports later on. Therefore we need to design them in a way that's nice and compatible.
Questions to answer
/wordpress
directory with release-specificwp-includes
andwp-admin
?wp-config.php
be exported?db.php
drop-in be exported?/wordpress
?/wordpress/wp-content
? Should that include customized/wordpress/wp-config.php
?/wordpress/wp-content/plugins/my-plugin
?/wordpress/index2.php
? Should Playground detect that / care?/internal
directory?/internal/mu-plugins/sqlite-database-integration
? It's referenced in/wordpress/wp-content/db.php
.Blueprint.json
with WordPress, PHP versions and env/constants included in the export?metadata.json
with{"oldUrl": "https://mysite.com", "requiresWp": "6.4"}
included in the export? Or is this handled with a Blueprint?https://playground.internal
?/
-based URLs?Other questions
cc @bgrgicak @dmsnell @brandonpayton
Beta Was this translation helpful? Give feedback.
All reactions