Skip to content

Conversation

@Mamaduka
Copy link
Member

These two post types were missing while working on the original ticket.

Gutenberg issue: WordPress/gutenberg#64733.
Trac ticket: https://core.trac.wordpress.org/ticket/41172


This Pull Request is for code review only. Please keep all other discussion in the Trac ticket. Do not merge this Pull Request. See GitHub Pull Requests for Code Review in the Core Handbook for more details.

@Mamaduka Mamaduka self-assigned this Aug 28, 2024
@github-actions
Copy link

github-actions bot commented Aug 28, 2024

The following accounts have interacted with this PR and/or linked issues. I will continue to update these lists as activity occurs. You can also manually ask me to refresh this list by adding the props-bot label.

Core Committers: Use this line as a base for the props when committing in SVN:

Props mamaduka, swissspidy, antonvlasenko.

To understand the WordPress project's expectations around crediting contributors, please review the Contributor Attribution page in the Core Handbook.

@Mamaduka
Copy link
Member Author

@swissspidy, I used the old Trac ticket as a reference. Should I create a new one?

@github-actions
Copy link

Test using WordPress Playground

The changes in this pull request can previewed and tested using a WordPress Playground instance.

WordPress Playground is an experimental project that creates a full WordPress instance entirely within the browser.

Some things to be aware of

  • The Plugin and Theme Directories cannot be accessed within Playground.
  • All changes will be lost when closing a tab with a Playground instance.
  • All changes will be lost when refreshing the page.
  • A fresh instance is created each time the link below is clicked.
  • Every time this pull request is updated, a new ZIP file containing all changes is created. If changes are not reflected in the Playground instance,
    it's possible that the most recent build failed, or has not completed. Check the list of workflow runs to be sure.

For more details about these limitations and more, check out the Limitations page in the WordPress Playground documentation.

Test this pull request with WordPress Playground.

@Mamaduka
Copy link
Member Author

It looks like an attempt was made to make the autosaves endpoint work for Templates and Template Parts (https://core.trac.wordpress.org/ticket/56922). These PHP unit tests are failing now.

How do we want to proceed here? Should we disable the PHP unit tests until these post types fully support autosaving?

Note: The autosaving is disabled on the client side - WordPress/gutenberg#64733.

@swissspidy
Copy link
Member

@swissspidy, I used the old Trac ticket as a reference. Should I create a new one?

Yes. New milestone/release = new ticket. The old ticket is already fixed on a closed milestone and must not be reopened/amended for changes in a new milestone.

How do we want to proceed here? Should we disable the PHP unit tests until these post types fully support autosaving?

I suppose we have to make up our minds here :-)

Just so I understand correctly:

[56819] added proper autosave support for wp_template and wp_template_part because previously the endpoints were sort of broken. (Commit message says: "Consequently, when the post types template and template part were introduced in [52062], it led to the registration of REST API endpoints for autosaves and revisions with invalid URL structures.")

But the editor never actually supported autosaves for wp_template anyway...? 🤔 Is that because it's not desired, or because it was previously broken?

If the former, we should update the core code here accordingly. If the latter, we should update Gutenberg, because it apparently seems to be supported by core.

So, which one is it?

@Mamaduka
Copy link
Member Author

Based on the latest comments on 56922 and new ticket, it seems that autosaves aren't fully working for Templates and Template Parts.

cc @anton-vlasenko, @ironprogrammer

@swissspidy
Copy link
Member

That one is labelled as an enhancement though, just updating the regex and adding some hardening.

@Mamaduka
Copy link
Member Author

The template parts and autosave endpoint still generate a warning. One I'm trying to fix in Gutenberg PR.

In any case, let's see what others think about this.

@anton-vlasenko
Copy link

anton-vlasenko commented Aug 28, 2024

That one is labelled as an enhancement though, just updating the regex and adding some hardening.

Correct. This is an enchancement and not a blocker.

The template parts and autosave endpoint still generate a warning.

I'm looking into the issue, @Mamaduka.

But the editor never actually supported autosaves for wp_template anyway...? 🤔 Is that because it's not desired, or because it was previously broken?

@swissspidy, I believe it’s the latter, as the default autosave endpoint doesn’t work for templates and template parts due to their different URL structure. These custom autosave and revision endpoints were supposed to address this issue, but as it can be seen, they didn’t fully resolve it.

I suggest to wait for the Core fix to arrive and avoid disabling autosaves for templates and template parts, unless there are other reasons to do so for these post types.
I'm currently working on the Core fix.

@anton-vlasenko
Copy link

I've fixed the issue with the autosaves endpoint.
The revisions endpoint is likely fixed as well, but I would like to write more unit tests to ensure it is fully resolved and to prevent it from occurring again.
The work is being done here: draft PR. The estimated time of completion is sometime tomorrow.

@Mamaduka, if you don't mind, I'm going to create a new Trac issue for this bug, as https://core.trac.wordpress.org/ticket/41172 doesn't seem to be an exact fit.

@Mamaduka
Copy link
Member Author

Thank you, @anton-vlasenko!

@anton-vlasenko
Copy link

anton-vlasenko commented Sep 2, 2024

Core ticket: https://core.trac.wordpress.org/ticket/61970
GH PR: #7272

The PR is ready for review. The error occurs because the Editor is trying to fetch autosaves for a file-based template. Since file-only templates do not have any entities in the database, it is impossible to fetch autosaves (or revisions) for them.

My PR addresses this issue by changing the REST response code from 403 to 400 when the controller attempts to get autosaves (revisions) for a file-only template (template part) and also fixes the fatal PHP error.
Additionally, it adds more unit tests to cover the wp_template_part post type.

I would appreciate your review and approval, @Mamaduka and @swissspidy.

This PR resolves the fatal error issue, but it will not enable autosaves automatically.
Should the Editor first check if the template has a database entity, and if not, create one?

@Mamaduka
Copy link
Member Author

Closing in favor of #7272.

@Mamaduka Mamaduka closed this Nov 13, 2024
@Mamaduka Mamaduka deleted the disable/autosave-endpoints-templates-and-parts branch November 13, 2024 06:26
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants