-
Notifications
You must be signed in to change notification settings - Fork 270
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
Website Query API: Add import-site
and import-content
options
#610
Website Query API: Add import-site
and import-content
options
#610
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is looking clean and small 👍
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
can we also add an item to the table of options in the Query API docs?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
it seems fine to allow import
without auto-login, and we can add something better afterwards. your call is good to auto-login or import given our options.
I left one minor comment @eliot-akira. The only other thing I'd change is I'd call this option |
OK, will do.
Sure, I will make the change. Just to confirm my understanding: so for now it will import the site and attempt to auto-login with the default user credentials. Even if the login fails, the rest of the steps (like install theme and plugins) should continue to run. When the "optional steps" feature is ready, then this login step can be made optional so that it doesn't throw an error and stop the install (in case the imported site doesn't have the default admin user). |
… but not implemented" This reverts commit 1253bb1.
OK, I made the suggested changes. I noticed that the query parameter More importantly.. Recently I was catching up on new developments in the Playground repo, and learned that the That means this current PR shouldn't be merged until the But on that topic: This also made me wonder, the name In this case I suppose the query parameter would be better named |
Oh you're right! I just started a PR to restore the importFile step #835
I wonder what would it take to call the appropriate PHP functions directly, I like that idea. Alternatively, we could use the new
I like the idea about reorganizing the names of these steps. |
It probably depends on how WordPress Importer works internally, if its import function is written in a way that's callable independently and programmatically, or if it's tightly coupled with the admin screen and form submit flow. In the latter case, maybe the majority of the existing
That sounds good to me, to include the expected file format in the step name. Or maybe
For this one, if there's a single common format to export/import a site (in its entirety or just the So there are ways to:
Looking at this, I can imagine there may be other export formats in the future, like: a "site diff" for only the changed files and database operations; or some kind of JSON format to create content; or importing an SQL file. In that case, it may be better to have step/function names that specify the expected file format, instead of abstract terms like "content" and "site". I tend to err on the side of user convenience, short and easy to type, like an |
For user research you may look at what specific import/export options popular cloud wordpress providers offer. I believing they typically have ways to replace sites (between staging/prod etc) as well as maybe ways to sync content across environments without necessarily syncing full site config but I'm rusty on WP now |
@eliot-akira this is unblocked now as #835 is merged.
That's fair, and I guess we'll need to go beyond
I like that idea! That could be an entirely new step that's a higher-level abstraction – it knows how to detect the input format, and then call a specific format-specific step. |
That sounds nice for a public interface like the Query API. OK, I'll work on the above points. It sounds simple enough, as a thin layer to create a blueprint step from the given query parameter. (I guess these steps cannot be used together? Maybe
@aehlke - Thank you for the suggestion. It's a good idea to see what existing import/export solutions there are. It reminds me of WP-CLI, how it has commands to import/export the database, and particularly its
It also makes me wonder whether it's possible in the future to run blueprint steps on regular WP sites outside of Playground. As the Blueprint API evolves, the more it seems like a useful abstraction for setting up a WordPress site in any context, including |
Actually I’m having second thoughts here. It’s easy to pattern match the file extension, but then extending support to, say, plugins or different site export formats could require unzipping the archive and reasoning about its contents — which feels like a big scope creep. |
True, there could be multiple export formats that use the If we can't rely on file extension to tell us the expected format - that means, instead of
It does feel a bit redundant to have the file extension in the step/query name, if they are the same. How about, if in the future we have different site export formats, their corresponding import/export step names could specify what they are..? |
I like that! |
…alue `0` to stop automatic login; Clarify that `import-content` depends on `login` to succeed
OK, the following options have been added to the website's Query API.
(These example URLs can be visited after running Also updated the documentation page to describe these options. Some points to note:
From what I understand, this applies to all query parameters that accept a URL, namely: |
import-site
(zip) and import-content
(wxr/wxz)
import-site
(zip) and import-content
(wxr/wxz)import-site
and import-content
import-site
and import-content
import-site
and import-content
options
|
||
:::info CORS policy | ||
|
||
To import files from a URL, such as a site zip package, they must be served with `Access-Control-Allow-Origin` header set. For reference, see: [Cross-Origin Resource Sharing (CORS)](https://developer.mozilla.org/en-US/docs/Web/HTTP/CORS#the_http_response_headers). |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Lovely note, thank you @eliot-akira! ❤️
@@ -33,11 +33,19 @@ You can go ahead and try it out. The Playground will automatically install the t | |||
| `url` | `/wp-admin/` | Load the specified initial page displaying WordPress | | |||
| `mode` | `seamless`, `browser`, or `browser-full-screen` | Displays WordPress on a full-page or wraps it in a browser UI | | |||
| `lazy` | | Defer loading the Playground assets until someone clicks on the "Run" button | | |||
| `login` | `1` | Logs the user in as an admin | | |||
| `login` | `1` | Logs the user in as an admin. Set to `0` to not log in. | |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Good catch, thank you @eliot-akira! I know it's not directly related to this PR, but it's such a small and useful change – let's keep it.
This is amazing @eliot-akira, thank you so much! ❤️ |
…review links (#861) The preview links attached to Pull Requests exported to GitHub are now using the new `import-site` Query API param merged in #610. Before this commit, these preview URLs used Blueprints, which were more verbose and difficult to modify by hand. ## Testing Instructions 1. Export a PR to GitHub, select "Also export a .zip file" 2. Confirm the preview link in the PR description uses the `?import-site=` query parameter and not a Blueprint 3. Confirm the preview link works
What is this PR doing?
Adds query parameter
import-site
andimport-content
to the Playground website's Query API.import-site
- Imports site files and database from a zip file specified by URL.import-content
- Imports site content from a WXR or WXZ file specified by URL.What problem is it solving?
Resolves #608.
import
GET parameter to grab a whole WordPress zip and load all its content. #608Testing Instructions
Start local server with
npm run dev
Visit the following URL and confirm site files and database have been imported:
http://localhost:5400/website-server/?php=8.0&wp=6.4&storage=none&import-site=https://raw.githubusercontent.com/dmsnell/playground-experiments/trunk/just-a-little-change/playground.zip
Visit the following URL and confirm site content has been imported:
http://localhost:5400/website-server/?php=8.0&wp=6.4&storage=none&networking=yes&import-content=https://raw.githubusercontent.com/WordPress/theme-test-data/master/themeunittestdata.wordpress.xml