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

Update @wordpress packages for 6.3 RC2 #4892

Closed

Conversation

tellthemachines
Copy link
Contributor

@tellthemachines tellthemachines commented Jul 24, 2023

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

Updated packages with bugfixes from WordPress/gutenberg#52863 and WordPress/gutenberg#52915.


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.

Copy link
Member

@ramonjd ramonjd left a comment

Choose a reason for hiding this comment

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

I went through the commit list in WordPress/gutenberg#52863 and tested functionality.

LGTM

@tellthemachines
Copy link
Contributor Author

Unit test failures seem to be due to this change; looking into it

Copy link
Contributor

@audrasjb audrasjb left a comment

Choose a reason for hiding this comment

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

THanks for the PR!
I have two docblock changes :)

'_wp_put_post_revision',
/**
* Keeps track of the revision ID for "rest_after_insert_{$post_type}".
*
Copy link
Contributor

Choose a reason for hiding this comment

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

It's missing a since declaration here :)

Copy link
Member

Choose a reason for hiding this comment

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

Ah, so anonymous functions should also receive @since?

Copy link
Member

Choose a reason for hiding this comment

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

Why are these all anonymous functions in the first place?

Makes it impossible for developers to unhook them.

Copy link
Member

Choose a reason for hiding this comment

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

I personally like anonymous functions for handling the footnote meta because it makes the way to move to handling postmeta revisions in a more standard way in 6.4.

Unless you think we'd still want the named functions after doing so?

Copy link
Member

Choose a reason for hiding this comment

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

That would indeed be an argument for keeping them, but not sure if that's the reason for it?

Copy link
Member

Choose a reason for hiding this comment

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

Because this is a temporary fix and to avoid having to rename/naming clashes

Copy link
Member

Choose a reason for hiding this comment

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

Does this seem like an appropriate reason for using anonymous functions to you, @swissspidy ? (+cc: @peterwilsoncc and @joemcgill ).

If not, do you think we should continue discussion about this in the existing issue about revision support or open a new issue?

It sounded like there may be platform considerations for using named functions here, and I want to make sure those are well understood.

Copy link
Member

Choose a reason for hiding this comment

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

It is, yes

src/wp-includes/blocks/footnotes.php Outdated Show resolved Hide resolved
* @param int $revision_id The revision ID.
*/
static function( $revision_id ) {
global $_gutenberg_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.

What about the gutenberg prefix here. Is that okay?

Copy link
Member

Choose a reason for hiding this comment

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

Also quite a hacky workaround in general having to use such a global here :/

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I understand this is a temporary situation until revisions properly support post meta in core.

Copy link
Member

Choose a reason for hiding this comment

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

Open for any better workarounds. It's quite late now to be adding general post meta revision support or start changing the REST API hook order.

global $_gutenberg_revision_id;

if ( $_gutenberg_revision_id ) {
$revision = get_post( $_gutenberg_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.

Wondering if we should use wp_get_post_revision here? It implements get_post, but has extra revision-specific checks that get_post doesn't.

Well, namely

	if ( 'revision' !== $revision->post_type ) {
		return null;
	}

😄

Copy link
Member

Choose a reason for hiding this comment

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

@joemcgill
Copy link
Member

I agree with the feedback about the way revisions are being handled in this PR not being ideal. However, I assume these changes will need to be made in the Gutenberg repo so they don't get overwritten during a future sync?

Copy link
Contributor

@peterwilsoncc peterwilsoncc left a comment

Choose a reason for hiding this comment

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

I agree with @swissspidy that it would be preferable to move the anonymous functions to named functions to allow developers to unhook them.

If this requires changes to the Gutenberg repo, then I think it's fine to commit as is for the purposes of this week's RC to allow a little extra time to get the upstream patches in.

@tellthemachines
Copy link
Contributor Author

Thanks for the feedback folks! We have to make a change in gutenberg already to address the PHP test errors, so I think we can do the renaming while we're at it.

@ramonjd
Copy link
Member

ramonjd commented Jul 25, 2023

Further fixes from WordPress/gutenberg#52915 will be updated in the packages

@ramonjd
Copy link
Member

ramonjd commented Jul 25, 2023

Further fixes from WordPress/gutenberg#52915 will be updated in the packages

Packages (wp/6.3) are ready for sync

@tellthemachines
Copy link
Contributor Author

Ok folks I think we've addressed all the feedback now!

@tellthemachines tellthemachines dismissed audrasjb’s stale review July 25, 2023 08:23

feedback has been addressed

}
}

foreach ( array( 'post', 'page' ) as $post_type ) {
Copy link
Member

Choose a reason for hiding this comment

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

Shouldn't this support all post types using the block editor and/or have revision support enabled?

Copy link
Member

Choose a reason for hiding this comment

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

I think this conversation / issue may be related:
WordPress/gutenberg#52812

Copy link
Member

Choose a reason for hiding this comment

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

@getsource
Copy link
Member

getsource commented Jul 25, 2023

I left this further up in the review, but thought it should be here as well so it ends up in the ticket.

My understanding was that the anonymous functions were being used to help with a move to handling postmeta revisions in a more standard way in 6.4.

Do y'all think we'd still want the named functions after doing so?
If not, is there an approach that would allow the developer control necessary + removing them in the future?

Edit: To be clear, given committer support above, I am not intending this comment as a blocker for merge for RC2, but for clarification + so the conversation happens.

@swissspidy
Copy link
Member

My understanding was that the anonymous functions were being used to help with a move to handling postmeta revisions in a more standard way in 6.4.

Maybe, but there's no explanation at WordPress/gutenberg#52686 from what I can see.

Do y'all think we'd still want the named functions after doing so?

If there's no concern with back compat / tech debt, I suppose we can keep them anonymous until 6.4 lands 👍


Another thing I find very concerning in general is that this post meta revision support is a late-stage enhancement with no unit tests at all.

Not to mention WordPress/gutenberg#52812

Right now I tend to agree with this comment by Ella:

this bug makes me think that footnotes is not ready for 6.3.

@getsource
Copy link
Member

getsource commented Jul 25, 2023

^ cc: @ellatrix in case you want to give any additional feedback on the couple concerns / topics being talked about

@tellthemachines
Copy link
Contributor Author

Another thing I find very concerning in general is that this post meta revision support is a late-stage enhancement with no unit tests at all.

I'm considering this to be a bug fix, not an enhancement, because it would not be expected that footnotes stay unchanged when reverting to a previous revision. The fact that this happens because footnotes are tied to post meta is an implementation detail; the behaviour is still buggy. I agree that it would be good to have some unit tests though.

Regarding the functions: I changed them to named functions based on the previous feedback. I'm not too concerned one way or the other as I guess the worst case is they'll have to be deprecated once proper support for post meta in revisions is implemented. But changing them back at this point will require a Gutenberg PR and re-publishing the npm packages, and my bedtime is fast approaching 😅 so I'll have to leave that for someone else to do.

Note that I've already committed this changeset to trunk here.

@ellatrix
Copy link
Member

There is an e2e test for revisions. We can add more flows if anyone sees a need.

@tellthemachines
Copy link
Contributor Author

Closing this one as it landed in the release branch in https://core.trac.wordpress.org/changeset/56305.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
No open projects
Development

Successfully merging this pull request may close these issues.

9 participants