WordPress / wordpress-playground

Run WordPress in the browser via WebAssembly PHP
https://w.org/playground/
GNU General Public License v2.0
1.64k stars 257 forks source link

Export and Import Playground instance #88

Closed adamziel closed 1 year ago

adamziel commented 1 year ago

Phase 1: Let's enable exporting the current Playground, including all the filesystem and database changes, as a downloadable file. Let's enable importing that bundle later on.

Phase 2: Let's include the current cookies, the open page, forms state, and even the scroll position.

This would open doors to:

Prior art:

adamziel commented 1 year ago

Also relevant: https://github.com/WordPress/wordpress-playground/issues/19

danielbachhuber commented 1 year ago

@adamziel Following up our thread:

Out of curiosity, what was the reasoning behind the decision to use the WordPress Importer, versus exporting whatever state file could be created to also address https://github.com/WordPress/wordpress-playground/issues/19

WordPress importer is interoperable with regular non-Playground WordPress sites – you can move sites between offline and in-browser in both directions.

Just so it's stated, highlighting a few downsides we may run into: uploaded media files won't be included, installed plugins won't be included, and options/users won't be included.

Any idea how to close that gap without building a dedicated Playground Importer plugin?

I don't think there's a silver bullet, unfortunately. 😞

The most common paths for WordPress export -> import workflow are:

  1. WordPress WXR - includes content from the database (posts, pages, navigation items, terms, etc.) but doesn't include uploaded media files, anything related to the options table (installed plugins, plugin configuration), or users.
  2. Database + wp-content directory ZIP - includes everything but can be quite large, contain data you don't actually want to include, and the exported database will overwrite whatever you already have in the database.

Worth noting some other challenges:

A long time back, I started a project to provide a solution in-between WXR and database + wp-content: https://github.com/boxuk/dictator

I stopped working on it because I didn't want to continue down the rabbit hole of abstracting the options table to YAML files. It also didn't solve the problem of media uploads.

To me, as a naive layperson, it seems like we could solve both this and #19 by creating a way to "dump" or "stash" all of the browser session-specific data into an archive, and then initiate a new browser session from that file. Even cooler is if we could store the user's current page, scroll position, etc., so you could "1 click" launch exactly where they were at.

adamziel commented 1 year ago

@akirk shared this with me:

adamziel commented 1 year ago

One more from @danielbachhuber: VersionPress – it's for versioning the database. It creates a filesystem representation of the WordPress database, writes a copy of the database to the filesystem with this abstraction, and uses native Git for version control.

Also:

Only MySQL holds all of the data. WXR is widely adopted.

adamziel commented 1 year ago

More thoughts: This issue has different import/export goals than WordPress core. WordPress Playground imports:

adamziel commented 1 year ago

Export/import for full site alworks for some time already. As for composability, Blueprints now allow that - including importing WXZ and WXR files. Let’s close this higher level issue and use smaller ones for any missing features that come up.