WordPress.org

Make WordPress Core

Opened 2 months ago

Closed 6 weeks ago

Last modified 6 weeks ago

#54448 closed defect (bug) (fixed)

Missing rest api endpoint when exporting templates and template parts

Reported by: walbo Owned by: TimothyBlynJacobs
Milestone: 5.9 Priority: normal
Severity: normal Version: trunk
Component: Editor Keywords: has-patch has-unit-tests
Focuses: rest-api Cc:

Description

In the Gutenberg plugin a rest api endpoint wp-json/__experimental/edit-site/v1/export are added and used when you export your templates.

This endpoint are missing in 5.9 and the export function isn't working.

Steps to reproduce:

  1. Active twenty twenty two theme.
  2. Goto: Appearance > Editor (beta)
  3. Click on "More tools & options" (the menu in the top right corner)
  4. Click on "Export"
  5. Nothing happends. Check network and confirm the endpoint it tries to use doesn't exist.

Change History (31)

#1 @TimothyBlynJacobs
2 months ago

  • Focuses rest-api added
  • Milestone changed from Awaiting Review to 5.9

Cc: @noisysocks. We should stabilize this endpoint first as well. Probably also should go into wp-block-editor/v1.

#2 @hellofromTonya
2 months ago

  • Keywords needs-patch added

@TimothyBlynJacobs Rob (@noisysocks) likely isn't online in time for 5.9 Beta 1 release today. Is this something that can be fixed before today's release?

#3 @TimothyBlynJacobs
2 months ago

This is being worked on in https://github.com/WordPress/gutenberg/issues/36515. I'll handle the commit for it if it is ready in time.

#4 @desrosj
8 weeks ago

Looks like this was fixed in GB-36559. @TimothyBlynJacobs are you able to sync that trunk at some point today?

#5 @TimothyBlynJacobs
8 weeks ago

  • Owner set to TimothyBlynJacobs
  • Status changed from new to assigned

Yep, can do!

This ticket was mentioned in PR #1936 on WordPress/wordpress-develop by Mamaduka.


8 weeks ago

  • Keywords has-patch has-unit-tests added; needs-patch removed

#7 @prbot
8 weeks ago

Mamaduka commented on PR #1936:

@TimothyBJacobs I'm not sure how to fix the fixtures/wp-api-generated.js error. Can you point me to developer documentation on how to fix this?

#8 @prbot
8 weeks ago

desrosj commented on PR #1936:

@Mamaduka You need to run the REST API unit tests in PHP, and then a new version of that file will get generated!

We should add an npm script to make that easier and more clear how to accomplish that.

#9 @prbot
8 weeks ago

Mamaduka commented on PR #1936:

Thanks, @desrosj.

Fixtures are updated now.

#10 @prbot
8 weeks ago

Mamaduka commented on PR #1936:

Thanks for the reminder. I need to rename the method in Gutenberg, and we should be good. All methods and files are in the compat folder and have the function_exists guard clause.

#11 @prbot
7 weeks ago

Mamaduka commented on PR #1936:

Thanks, @walbo.

This ticket was mentioned in Slack in #core by hellofromtonya. View the logs.


7 weeks ago

#13 @prbot
7 weeks ago

peterwilsoncc commented on PR #1936:

@Mamaduka I've merged trunk in to your branch to resolve some merge conflicts

This ticket was mentioned in Slack in #core-restapi by hellofromtonya. View the logs.


7 weeks ago

This ticket was mentioned in Slack in #core by hellofromtonya. View the logs.


7 weeks ago

#16 @hellofromTonya
7 weeks ago

  • Keywords commit added

@TimothyBlynJacobs shared in Slack:

Looks good to me. I’d say go ahead and commit it.

Marking PR 1936 for commit.

#17 @spacedmonkey
7 weeks ago

  • Resolution set to fixed
  • Status changed from assigned to closed

In 52286:

Site Editor: Add site export REST API endpoint.

Add a REST API to export site templates and template part as html files. When the REST API is requested, it responds by downloading a single ZIP file and exits early, without completing full request. To create the exported zip, the ZipArchive class is required. If this class is not present then the export will gracefully fail, returning a WP_Error object and 500 status error code.

Props spacedmonkey, youknowriad, Mamaduka, walbo, peterwilsoncc.
Fixes #54448 .

#18 @prbot
6 weeks ago

Mamaduka commented on PR #1936:

Thanks for the fantastic feedback, @peterwilsoncc.

I always struggle with DocBlock comments. Now that API got merged, should I create separate PR for those.

#19 @dlh
6 weeks ago

  • Resolution fixed deleted
  • Status changed from closed to reopened

[52286] doesn't return the error in \WP_REST_Edit_Site_Export_Controller::permissions_check(), only creates it. The method always returns true. The error code also appears to be copied from \WP_REST_URL_Details_Controller.

#22 @spacedmonkey
6 weeks ago

Good catch @dlh .

I created a patch and added some much needed until tests in #2008.

#23 @prbot
6 weeks ago

spacedmonkey commented on PR #2008:

CC @dlh01

#24 @prbot
6 weeks ago

dlh01 commented on PR #2007:

Now #2008.

#25 @prbot
6 weeks ago

spacedmonkey commented on PR #2008:

CC @Mamaduka

#26 @prbot
6 weeks ago

Mamaduka commented on PR #2008:

Thanks for the follow-up, @spacedmonkey. The code looks good to me.

#27 @prbot
6 weeks ago

TimothyBJacobs commented on PR #2008:

Great catch @dlh01, thanks for that!

This looks fine to me @spacedmonkey. If you wanted, we could consider instead making an OPTIONS request and checking the Allow header. That way, if the test fails, it doesn't kill the test suite execution because of the die() call. But I think this is fine as is.

#28 @hellofromTonya
6 weeks ago

  • Keywords commit removed

Resetting the commit keyword which applied to the patch before the ticket was reopened.

This ticket was mentioned in Slack in #core by hellofromtonya. View the logs.


6 weeks ago

#30 @spacedmonkey
6 weeks ago

  • Resolution set to fixed
  • Status changed from reopened to closed

In 52340:

REST API: Ensure that the export template endpoint returns a valid WP_Error object.

Ensure that the export template endpoint returns a WP_Error object, including code and message, so that the site editor can display an error message.
Add some basic unit tests to ensure that permission checks are working as expected.

Follow-up to [52286].

Props Spacedmonkey, dlh, hellofromTonya , Mamaduka, TimothyBlynJacobs.
Fixes #54448.

This ticket was mentioned in Slack in #core by costdev. View the logs.


6 weeks ago

Note: See TracTickets for help on using tickets.