-
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
Backport #2576 to Gutenberg #40902
Backport #2576 to Gutenberg #40902
Conversation
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.
Hi @anton-vlasenko,
By accident on #41791, I needed another change to the pattern endpoint and ended up doing the objective of this PR.
I think we need a new file for the patterns endpoint. The changes in lib/compat/wordpress-6.0/class-wp-rest-block-patterns-controller.php don't have a practical effect because the file is not used at all if the core already includes the class:
if ( ! class_exists( 'WP_REST_Block_Patterns_Controller' ) ) {
require_once __DIR__ . '/compat/wordpress-6.0/class-wp-rest-block-patterns-controller.php';
}
So when we need to change the endpoint in the plugin we will not be able to do so because this file is ignored.
In I'm creating a new file lib/compat/wordpress-6.1/class-gutenberg-rest-block-patterns-controller.php that contains a new class Gutenberg_REST_Block_Patterns_Controller overwriting the core one during the backports we just need to pass the class to the core and change its name. So in the plugin, we are free to apply the multiple changes we will need on the endpoint. If you prefer I can extract these changes to the endpoint in a separate PR so we can review the approach.
I believe that's the desired behavior here. This PR adjusts the included compat controller to behave the same way that Core behaves, so users running the plugin on WP 5.9 have identical behavior. |
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.
LGTM 👍 We can and should change lib/compat/wordpress-6.0/class-wp-rest-block-patterns-controller.php to match core although on #41791 I'm adding a new Gutenberg class so we can extend the core. I guess both PRs can be merged. And after both are merged we can just remove this file and start relying on the Gutenberg one.
Hi @jorgefilipecosta |
What?
This PR aims to backport changes from WordPress/wordpress-develop#2576 to Gutenberg.
Fixes #40824.
Why?
This is needed to keep Core and Gutenberg as compatible as possible.
Testing Instructions
Replace
with the actual credentials.
Replace
with the actual URL of your instance.
6. Note the response. It must contain block patterns.