WordPress / wordpress-playground

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

importWordPressFiles should leave directories untouched that are not in the ZIP file #1992

Open akirk opened 6 days ago

akirk commented 6 days ago

In the docs it says:

Any files that Playground recognizes as “excluded from the export” will carry over from the existing document root into the imported directories. For example, the sqlite-database-integration plugin.

I read this as: if a ZIP file specificed doesn't include a wp-content directory, it should be left untouched.

bgrgicak commented 6 days ago

By looking at the code it looks intentional that we overwrite the wp-content folder. The documentation part you shared is confusing to me. It's not clear what “excluded from the export” means (It's this list).

How could we phrase this differently?

Technical details

This is happening because we overwrite the entire wp-content folder.

Even if the ZIP doesn't contain a wp-content folder the importWordPressFiles step will create it because it copies Playground related files from the live site into the imported site.

adamziel commented 4 days ago

I don't like how that step works today. It was through way too many iterations without proper importing tools. Luckily, we have more tooling now (URL rewriter, block markup parser, internal Playground directory). Let's take a step back, forget about any existing assumptions, and discuss the most useful possible version of a ZIP import.

First, I don't like having a special list of files excluded from the export. Initially, it was just a way to exclude the platform-level mu-plugins from the export. These days we don't ship them anymore, so that's a solved problem. Removing that list would break a few export files that are 12+ months old – I think that's okay. Once we remove that list, we can get rid of that confusing part of the documentation.

Thinking forward, I wonder what kinds of ZIP files would be useful to support? The snapshots support explores that question.

So we'd either import wp-content plus some top-level files, or a full WordPress site. I don't see a scenario where there's no wp-content in the archive.

By the way! This is the same problem space as @brandonpayton is exploring in https://github.com/WordPress/blueprints-library/issues/117.

adamziel commented 4 days ago

Also, I don't want to make any further adjustments in the TypeScript "import site" step. Everything I said, I meant for the PHP importer.

brandonpayton commented 1 day ago

Challenge: What if there are relevant content files outside of the wp-content directory – right at the root level of the site? To capture them, we'd need to zip up everything except of the files bundled with the current WordPress release. It seems fuzzy but perhaps there's a way to make it reliable.

Maybe content outside of wp-content should be considered Doing It Wrong. We could support some kind of escape hatch (like an option to grab other specific dirs if present), but isn't the purpose of wp-content to contain all the content?