Skip to content
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

Blueprints: use humanmade/WordPress-Importer in the importFile step #1183

Closed
adamziel opened this issue Apr 2, 2024 · 1 comment · Fixed by #1192
Closed

Blueprints: use humanmade/WordPress-Importer in the importFile step #1183

adamziel opened this issue Apr 2, 2024 · 1 comment · Fixed by #1192
Milestone

Comments

@adamziel
Copy link
Collaborator

adamziel commented Apr 2, 2024

The importFile step works by interacting with HTML form like a user would. Problem is, the WXR importer requires some interactions with the forms which we fake by adjusting the POST data before submitting the form. This approach causes a number of issues:

It seems like the humanmade/WordPress-Importer WXR importer provides a PHP API we could use to configure and run the importing process using just PHP, solving all of the above issues:

$options = array(
	'fetch_attachments' => true,
	'default_author' => $admin_id
);
$importer = new WXR_Importer( $options );
$result = $importer->import( $path );

cc @brandonpayton

@flexseth
Copy link
Collaborator

flexseth commented Apr 3, 2024

Looks clean!

$options = array(
	'fetch_attachments' => true,
	'default_author' => $admin_id
);
$importer = new WXR_Importer( $options );
$result = $importer->import( $path );

adamziel added a commit that referenced this issue Apr 3, 2024
…ress-Importer

Rewires the importFile step to:

* Be named importWxz. The old name continues to work, though.
* Use the humanmade/WordPress-Importer for importing content – it is
  more reliable than the official wordpress-importer and has a
  convenient PHP API.
* Drop WXZ support – it's a maintenance burden and doesn't add clear
  value.

Closes #1183
Closes #379
Closes #1158
Closes #1161
adamziel added a commit that referenced this issue Apr 4, 2024
…ress importer (#1192)

The importFile step works by interacting with HTML form like a user
would. Problem is, the WXR importer requires some interactions with the
forms which we fake by adjusting the POST data before submitting the
form. This approach causes a number of issues listed below.

More context:
#1183.

## Implementation

Refactors the importFile Blueprint step to:

* Be named importWxz. The old name continues to work, though.
* Use the humanmade/WordPress-Importer for importing content – it is
  more reliable than the official wordpress-importer and has a
  convenient PHP API.
* Drop WXZ support – it's a maintenance burden and doesn't add clear
  value.
* Remove dependency on DOMParser – this step should now work in `wp-now`

## Testing instructions

1. Go to
http://localhost:5400/website-server/?import-wxr=https://raw.githubusercontent.com/helgatheviking/Simple-User-Listing/3e38ea3eb3a057424fbae4305cba2fd9f73d896b/demo-content/demo-content.xml&php=8.0&wp=6.5&storage=none&php-extension-bundle=kitchen-sink
2. Confirm the "Simple User Listing Block" page was created
3. Confirm in wp-admin a bunch of user accounts were created
4. Confirm in wp-admin the WordPress Importer plugin was installed

Closes #1183
Closes #379
Closes #1158
Closes #1161

cc @dmsnell
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
Archived in project
2 participants