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

Footnotes: footnotes are not reverted or restored with post revisions #52541

Closed
ramonjd opened this issue Jul 12, 2023 · 14 comments · Fixed by #52686
Closed

Footnotes: footnotes are not reverted or restored with post revisions #52541

ramonjd opened this issue Jul 12, 2023 · 14 comments · Fixed by #52686
Assignees
Labels
[Block] Footnotes Affects the Footnotes Block [Type] Bug An existing feature does not function as intended

Comments

@ramonjd
Copy link
Member

ramonjd commented Jul 12, 2023

Description

When restoring a post's revision, the footnotes associated with that revision are not restored.

Only the latest version of the post's footnotes will appear on the page at any one time.

The consequence is that users can't access a "true" record of a post's changes.

First noticed here.

Step-by-step reproduction instructions

  1. Create a new post
  2. Add some text in a paragraph
  3. Add a footnote or two using he block inspector toolbar
  4. Save the post
  5. Repeat
  6. Save the post
  7. Restore the previous version
  8. Note that the text has been restored but the footnotes have not.

Screenshots, screen recording, code snippet

2023-07-12.14.12.22.mp4

Environment info

Gutenberg 16.2
WordPress 6.3-beta3-56201 running Twenty Twenty-Three theme.

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

@ramonjd ramonjd added [Type] Bug An existing feature does not function as intended [Block] Footnotes Affects the Footnotes Block labels Jul 12, 2023
@bph bph moved this to ❓ Triage in WordPress 6.3.x Editor Tasks Jul 12, 2023
@firoz2456
Copy link

@ramonjd
I would be grateful if you could post a video instead of a GIF. The GIF is playing too fast to understand the issue.

@ramonjd
Copy link
Member Author

ramonjd commented Jul 12, 2023

I would be grateful if you could post a video instead of a GIF. The GIF is playing too fast to understand the issue.

Thanks for the nudge @firoz2456

Updated 👍🏻

@firoz2456
Copy link

WordPress 6.3-beta4-56216
After several attempts, I was able to reproduce the issue.

Footnotes.revisions.not.working.mp4

@ramonjd
Copy link
Member Author

ramonjd commented Jul 14, 2023

There's a record in the wp_postmeta table that contains footnotes data for a particular post_id, e.g.,

post_id: 4
meta_key: footnotes
meta_value: [{"content":"Vestibulum sed diam at nulla luctus feugiat","id":"b208aa51-801d-4538-92d9-8b1aad7c05aa"},{"content":"Nunc sed dolor libero","id":"597a0e21-41d8-47d5-b5f1-894262c23cd1"}]

I haven't tested it too deeply, but a combination of the following hook might get close to where we want to be:

  1. save_post (or maybe post_updated)- check if the post's parent has revision meta, if so save a new meta entry with the updated footnotes against the revision id
  2. wp_restore_post_revision - fetch the footnotes meta associated with the restored revision and restore it to the post parent's meta (the one that is used on the frontend) using update_post_meta
  3. _wp_post_revision_fields and _wp_post_revision_field_footnotes - display the current revision's footnotes meta on the revision.php page.
Screenshot 2023-07-14 at 11 29 50 am

One downside could be is that it would create a new record in wp_postmeta every time a post with footnotes is updated.

@getsource
Copy link
Member

For reference, here is the core trac ticket regarding supporting revisions for post meta:
https://core.trac.wordpress.org/ticket/20564

@ramonjd
Copy link
Member Author

ramonjd commented Jul 14, 2023

For reference, here is the core trac ticket regarding supporting revisions for post meta:

Wow, that one has grey hairs 😆 10 years and still kicking!

@ndiego
Copy link
Member

ndiego commented Jul 14, 2023

@ramonjd given that this is related to that Trac issue, should this be punted?

@annezazu
Copy link
Contributor

I believe it should be punted and we should look into this for a future release.

@ramonjd
Copy link
Member Author

ramonjd commented Jul 14, 2023

given that this is related to that Trac issue, should this be punted?

Sounds good to me, thanks 👍🏻

@ndiego ndiego moved this from ❓ Triage to 🦵 Punted to 6.4 in WordPress 6.3.x Editor Tasks Jul 17, 2023
@ellatrix
Copy link
Member

Why is this being punted? This seems like a really bad issue to me. People rely on revisions and we're not saving footnotes? That's content loss.

@ndiego
Copy link
Member

ndiego commented Jul 17, 2023

This seems like a really bad issue to me. People rely on revisions and we're not saving footnotes? That's content loss.

💯 It is a really bad issue. But my understanding is that a fix requires https://core.trac.wordpress.org/ticket/20564 to be merged in 6.3, which sadly appears unlikely at this point.

@github-actions github-actions bot added the [Status] In Progress Tracking issues with work in progress label Jul 17, 2023
@Mamaduka
Copy link
Member

I personally would like to see the "post meta in revisions" issue resolved properly instead of adding a custom handler for footnotes.

@adamsilverstein
Copy link
Member

Note the code on https://github.com/adamsilverstein/wp-post-meta-revisions is more up to date that what is on the trac ticket. I will try to post an updated patch there. We can work on trying to land this in core, in the meantime GB could use the plugin code to revision footnote meta if desired.

@adamsilverstein
Copy link
Member

I tested revisioning footnotes meta using the plugin and observed it worked mostly - I experienced the "off by one" issue related to the timing of the save.

@github-project-automation github-project-automation bot moved this from 🦵 Punted to 6.4 to ✅ Done in WordPress 6.3.x Editor Tasks Jul 19, 2023
@priethor priethor removed the [Status] In Progress Tracking issues with work in progress label Jul 24, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
[Block] Footnotes Affects the Footnotes Block [Type] Bug An existing feature does not function as intended
Projects
No open projects
Development

Successfully merging a pull request may close this issue.

9 participants