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

Templates and Template part revision history shows wrong first revision #49164

Open
draganescu opened this issue Mar 17, 2023 · 13 comments · May be fixed by #67125
Open

Templates and Template part revision history shows wrong first revision #49164

draganescu opened this issue Mar 17, 2023 · 13 comments · May be fixed by #67125
Labels
[Feature] History History, undo, redo, revisions, autosave. [Feature] Templates API Related to API powering block template functionality in the Site Editor Needs Design Feedback Needs general design feedback. [Type] Bug An existing feature does not function as intended

Comments

@draganescu
Copy link
Contributor

Description

When editing for the 1st time a template or template part and saving, the result of the edit is saved in the database. That becomes the 1st version of the post saved. This is erroneous because compared to the original version saved on disk, the 1st version saved in the database contains edits. This leads to a poor UX like the one described in #48610 where users think their edits have not been saved as a revision.

The templates and template parts are not in the database and the 1st time they're edited they're basically added to the database, along with their edit. This shows up as two revisions, one with an empty post and one with the post having all the content (including the 1st edit).

Starting only with the 2nd edit, which will result in 3 available revisions, will we see actual diffs.

Step-by-step reproduction instructions

  1. Start a fresh WordPress install with Gutenberg 15.2 installed and
  2. Open the Site Editor and open a template or template part to
  3. Add a paragraph with text to the template and save the changes.

You can check for template revisions immediately, or after closing and re-opening the Site Editor. But none will.

  1. Edit the template again and make a different change, like adding an image, and saving the changes.

After this edit - revisions will start showing.

props @jordesign

Screenshots, screen recording, code snippet

revisions-after-one-edit.mp4

Environment info

No response

Please confirm that you have searched existing issues in the repo.

Yes

Please confirm that you have tested with all plugins deactivated except Gutenberg.

Yes

@jordesign
Copy link
Contributor

Brilliant - thanks @draganescu

@talldan
Copy link
Contributor

talldan commented Apr 17, 2023

@draganescu What technical feedback do you need? It seems like the cause of the problem is explained in the description, so I'll remove the label.

I guess technically 'Clear customizations' is the same as resetting to the original revision.

Given revisions are a big part of phase 3, it may not be worth tackling this fully until then, there may be some quick wins though, like showing the 'clear customizations' button in that sidebar.

@talldan talldan removed the Needs Technical Feedback Needs testing from a developer perspective. label Apr 17, 2023
@draganescu
Copy link
Contributor Author

The technical feedback should have been around the basic idea of using posts that are saved on disk and loading them in the DB after 1st edit. There are options to auto-create 1st revision automagically etc.

@annezazu annezazu changed the title Wrong 1st revision for templates and template parts Templates and Template part revision history shows wrong first revision May 16, 2023
@ramonjd
Copy link
Member

ramonjd commented May 31, 2023

Quoting @talldan about a possible UX-based approach to mitigate any confusion until phase 3:

I think a quick fix could be something like:

  • template exists only as a file - no revisions
  • template exists as a post with a single edit - show the ‘clear customizations’ option, but maybe styled to look similar to
    revisions, it could open a dialog to say that the template will be reverted back to the theme version
  • template exists as a post with multiple edits - show the normal revision system

@annezazu
Copy link
Contributor

annezazu commented Feb 6, 2024

I'd like to add this to the 6.5 board #54503 but we seem close on time to get a fix in place for the release in a week. If anyone can take this on, let me know and let's get it added. Otherwise, leaving out for now.

@mrfoxtalbot
Copy link

This is still an issue, @annezazu. Whose sleeve can I tug to get it fixed? Thanks!

@ramonjd
Copy link
Member

ramonjd commented Jun 3, 2024

Whose sleeve can I tug to get it fixed? Thanks!

I won't get time for a while, but I double checked to reacquaint myself with the issue and I still think that @talldan's suggestion above is a valid approach.

It's confusing when the side-by-side revisions view doesn't display the correct, or any, previous revisions so rather than hide the link to revision.php Gutenberg displays a "Clear customizations" or something for the first revision. This would also reflect the practical reality that the first edit of a theme file is not, according to the database, a revision post type, but a first "user" version.

What do folks think?

@annezazu
Copy link
Contributor

annezazu commented Jun 5, 2024

I would be curious to explore that approach and try it out! I think it could work.

@mrfoxtalbot
Copy link

That could work, thank you for taking a look, @ramonjd!

@ramonjd
Copy link
Member

ramonjd commented Sep 5, 2024

I'm still looking at options on this. Jotting down some notes from today:

  • Out of curiosity, I looked at trying to "fake" an initial revision in revision.php by fetching the original file matching it with the revision post slug, but, as it's not a revision record, too much fudging is required, plus we'd have to handle patterns as well. That seems like a dead end.
  • Another thing I'd like to try is the idea above, to create an initial "revision" when a template is created.
  • Failing that, at UI-first approach could be the way to go.

@richtabor
Copy link
Member

How big of an issue is this? Feels a bit obscure (thinking on priority).

@ramonjd
Copy link
Member

ramonjd commented Sep 5, 2024

How big of an issue is this? Feels a bit obscure (thinking on priority).

My personal read of its 'bigness' is mild to lukewarm. Even on issues like Automattic/wp-calypso#74685

That revisions (2) only appear after having saved the template three times is pretty weird - it's a side-effect of the way Core handles changes to template files.

Maybe a small UI change could mitigate it, but I'd question the value of going any deeper right now.

What do other folks think?

@talldan
Copy link
Contributor

talldan commented Sep 17, 2024

Sharing a connected issue - #52221.

I think the two are connected, as the incorrect revision history would make preserving/resetting the history not work correctly. 🤔

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
[Feature] History History, undo, redo, revisions, autosave. [Feature] Templates API Related to API powering block template functionality in the Site Editor Needs Design Feedback Needs general design feedback. [Type] Bug An existing feature does not function as intended
Projects
None yet
Development

Successfully merging a pull request may close this issue.

7 participants