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

Add revisioning of post meta, including ‘footnotes’ by default #4859

Closed
wants to merge 117 commits into from

Conversation

adamsilverstein
Copy link
Member

@adamsilverstein adamsilverstein commented Jul 17, 2023

Trac ticket: https://core.trac.wordpress.org/ticket/20564

Related Gutenberg Ticket: WordPress/gutenberg#52988


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.

@adamsilverstein
Copy link
Member Author

See WordPress/gutenberg#52686

@Mamaduka
Copy link
Member

@adamsilverstein, should we try using register_meta for enabling post meta revisions instead of wp_post_revision_meta_keys filter?

@adamsilverstein
Copy link
Member Author

@adamsilverstein, should we try using register_meta for enabling post meta revisions instead of wp_post_revision_meta_keys filter?

Sure, good idea - I'll give it a try

@spacedmonkey
Copy link
Member

Pinging @swissspidy as this change may effect the web stories plugin that has a custom revision / autosave endpoint.

Copy link
Member

@spacedmonkey spacedmonkey left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I tested this with the web stories plugin that has many custom post types and meta. Seems to work well. Just some little bits of feedback and we should be nearly ready to commit.

adamsilverstein and others added 5 commits September 26, 2023 07:54
…troller.php

Co-authored-by: Jonny Harris <spacedmonkey@users.noreply.github.com>
…troller.php

Co-authored-by: Jonny Harris <spacedmonkey@users.noreply.github.com>
Co-authored-by: Pascal Birchler <pascal.birchler@gmail.com>
Co-authored-by: Pascal Birchler <pascal.birchler@gmail.com>
$revision_id = _wp_put_post_revision( $post_data, true );
}

if( is_wp_error( $revision_id ) ) {
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@spacedmonkey thinking we should check for 0 here as well since _wp_put_post_revision can return 0.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

How about this?

if( 0 === $revision_id ) {
    return new WP_Error(...
}

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

$revision_id could be 0 OR a wp_error here so I think we need to check for both which is what I did.

@spacedmonkey
Copy link
Member

Do we need to update wp_create_initial_post_meta?

adamsilverstein and others added 2 commits September 26, 2023 09:01
…troller.php

Co-authored-by: Jonny Harris <spacedmonkey@users.noreply.github.com>
@adamsilverstein
Copy link
Member Author

Do we need to update wp_create_initial_post_meta?

Not sure, I'm going to get this committed then we can revisit during beta.

Comment on lines +503 to +504
// Restore any revisioned meta fields.
wp_restore_post_revision_meta( $post_id, $revision['ID'] );
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
// Restore any revisioned meta fields.
wp_restore_post_revision_meta( $post_id, $revision['ID'] );

@adamsilverstein This is not need anymore, as it hooked in the next line.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

👍🏼 will commit in a follow up

Copy link
Member

@spacedmonkey spacedmonkey left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good to commit. We will follow up with any issues.

@adamsilverstein
Copy link
Member Author

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.

7 participants