close
Skip to content

Fix : Revisions for templates#66231

Closed
Vrishabhsk wants to merge 2 commits intoWordPress:trunkfrom
Vrishabhsk:fix/template-revisions
Closed

Fix : Revisions for templates#66231
Vrishabhsk wants to merge 2 commits intoWordPress:trunkfrom
Vrishabhsk:fix/template-revisions

Conversation

@Vrishabhsk
Copy link
Copy Markdown
Contributor

What?

  • Allow revisions for templates to be accessible when there's at least 1 available
  • Update test to handle 0 and 1 revision scenarios

Why?

When I try to edit the Blog Home template or the Index template, the Revisions section starts showing only after I make three edits to the template. I expect the revisions to start displaying right after the first edit.

How?

  • Reduce the count condition in PostLastRevisionCheck wrapper

@github-actions
Copy link
Copy Markdown

github-actions bot commented Oct 18, 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.

If you're merging code through a pull request on GitHub, copy and paste the following into the bottom of the merge commit message.

Co-authored-by: Vrishabhsk <vrishabhsk@git.wordpress.org>
Co-authored-by: miminari <mimitips@git.wordpress.org>

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

@Vrishabhsk
Copy link
Copy Markdown
Contributor Author

Issues

  • While implementing this fix, I came across a bug related to the Template revisions
  • When the first change is made and saved, a revision isn't created (ideally, it should)
  • After the second change, the revision is considered but when we visit revision.php:
    • it shows the changes as if the template was created.
    • It should ideally show the change made to the template
  • Now when we make another change (3rd change), it works as expected and shows the change we implemented

How to recreate

  • Edit any one of the templates of a FSE theme
  • Press Save and ideally it should render the Revisions component in the settings panel, which it doesn't
  • Make another change (2nd change) and the Revisisons component render correctly showing count as 1
  • When we are redirected to revision.php after clicking the count, it will show the entire content under a + sign on the right side of comparison instead of the change actually implemented

Let me know your thoughts on this. cc @CacheMeOwside @miminari

@miminari
Copy link
Copy Markdown
Member

Thanks for committing to this, but it doesn't seem like a bug, it's a specification. Please check below:

Only show the revisions panel if at least 2 revisions exist. The revisions screen is not designed to display a single revision and is broken in this state. This behavior matches the current core behavior.
#3511

I’m sorry but I just added the “Needs testing” label. First, we should check if the issue can be reproduced and if it needs to be fixed.

There might be some issues due to the lack of revision generation during the first and second time. We can discuss ways to improve the system; However, this could involve major modifications that would also need to be considered at the Core.

@Mamaduka
Copy link
Copy Markdown
Member

Thanks for contributing, @Vrishabhsk!

As @miminari noted, the check here was intentional. The solution requires changing how templates work in WP; see #49164 for additional details.

I'm going to close the PR.

@Mamaduka Mamaduka closed this Oct 20, 2024
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