-
Notifications
You must be signed in to change notification settings - Fork 4.2k
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
Fix Gutenberg 11.8.2 in WordPress trunk #36347
Conversation
@@ -115,7 +115,7 @@ function block_core_calendar_update_has_published_posts() { | |||
* | |||
* @param int $post_id Deleted post ID. | |||
*/ | |||
function block_core_calendar_update_has_published_post_on_delete( $post_id ) { | |||
function gutenberg_block_core_calendar_update_has_published_post_on_delete( $post_id ) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This can be a problem. I think block PHP files are automatically copied into WP core during package updates, and we can't have the gutenberg_
prefix there.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
🤔 This and the other change in this file were causing fatals as well. What would be the proper fix?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Sorry, I'm not sure. I know Nik (@ntsekouras) renamed a bunch of functions last week, maybe he knows what's the proper fix.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think block PHP files are automatically copied into WP core during package updates, and we can't have the gutenberg_ prefix there.
That's correct. How this function creates any problem as is only used from this block? It would be a problem if it did call a gutenberg
prefixed function that made it into core (example PR.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hey, this is what I know. Without these fixes I get this error when activating the plugin (11.8.2 version) with the latest WordPress core:
I also see that the functions block_core_calendar_update_has_published_post_on_transition_post_status
and block_core_calendar_update_has_published_post_on_delete
were backported to WordPress core as of this commit (see related PR).
So, the fact that the plugin uses the same names is why the error happens, and renaming them fixes it. What I'm unfamiliar with is how packages/block-library/src/calendar/index.php
in Gutenberg is converted into the src/wp-includes/blocks/calendar.php#L151
in WordPress core, but I presume is part of the package update. In any other file, I'd rename the functions to something different. How do we update this kind of files?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm changing the block calendar code to cover against the function being already present at 601a012 so it doesn't require a package update. Props @jorgefilipecosta
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Removed the conditional functions to avoid issues with the build step of Gutenberg that renames the functions in block files.
The failures happening here are already happening in the release branch 11.8, I wonder why they're not happening on trunk, maybe there's something else that need to be backported |
Anyway, I guess It shouldn't block this PR. |
@youknowriad: I'm confused, which bit of this did you want to backport to Core? The base is |
I thought this one was also meant to be cherry-picked to |
Co-authored-by: Riad Benguella <[email protected]>
Note this PR has
release/11.8
as its base branch.Activating the Gutenberg 11.8.2 plugin with the latest WordPress core
trunk
causes an error due to some name clashes:WP_Theme_JSON_Schema
(this PR renames it to beWP_Theme_JSON_Schema_Gutenberg
)block_core_calendar_update_has_published_post_on_delete
andblock_core_calendar_update_has_published_post_on_transition_post_status
already exist in core, so this PR only defines them if they don't exist.Note that Gutenberg 11.9 is expected to be released tomorrow, so that should be the preferred fix. This PR only exists to help with a potential 11.8.3, should it happen. See conversation in core-editor slack (requires registration).
cc @Mamaduka @priethor
How to test