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

Changes for FSE backport in core #36201

Merged
merged 20 commits into from
Nov 5, 2021

Conversation

ntsekouras
Copy link
Contributor

Changes for the FSE back porting in core.

Related: WordPress/wordpress-develop#1796

It's still in progress and will have more changes..

@@ -165,72 +165,6 @@ function _gutenberg_add_template_part_area_info( $template_info ) {
return $template_info;
}
Copy link
Contributor

Choose a reason for hiding this comment

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

I think you should be able to move all the functions from this file into the new block-template-utils.php file

@@ -339,7 +339,7 @@ public function delete_item( $request ) {
* @return stdClass Changes to pass to wp_update_post.
*/
protected function prepare_item_for_database( $request ) {
$template = $request['id'] ? gutenberg_get_block_template( $request['id'], $this->post_type ) : null;
$template = $request['id'] ? get_block_template( $request['id'], $this->post_type ) : null;
$changes = new stdClass();
if ( null === $template ) {
$changes->post_type = $this->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.

This endpoint can also be moved to the 5.9 folder

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 saw that the controller was introduced in 5.8. Should I put the whole controller under 5.9 folder? 🤔

Copy link
Contributor

Choose a reason for hiding this comment

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

5.9 because it changed between the two versions, so it should only be removed after 5.9 is the minimum version.

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'm not sure how to handle the endpoint here, as in load I guess we should have the check for if the class exists, but this will be true for 5.8 as well.

Copy link
Contributor

Choose a reason for hiding this comment

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

Yeah, I think we could check something that only exists on 5.9 and have a comment there. Also the call registering the endpoint should use the same check and same comment.

Copy link
Contributor

Choose a reason for hiding this comment

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

Also we should keep the class name different in order to be able to register it in 5.8 even if it already exists (Gutenberg prefix)

Copy link
Contributor Author

Choose a reason for hiding this comment

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

If we keep the prefix, do we need a 5.9 check?

Copy link
Contributor

Choose a reason for hiding this comment

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

do we need a 5.9 check?

Not necessarily because the versions are exactly the same, that said, I think keeping the check is important for one case: imagine if in the future, we need to make changes to the endpoint, this means the endpoint need to move to wordpress-6.0 folder but if we don't have the check in place, we won't notice it and we could update it but keep it in wordpress-5.9 which means we'll forget about it when it comes time to make backports for 6.0

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Hm.. okay. I think this is coupled with the registration of the post types (wp_template and wp_template_part) handling as well (rest_controller_class prop) and we can check it in a follow up? I guess a check for Gutenberg_REST_Global_Styles_Controller would be a good candidate when the patch makes it to core?

Copy link
Contributor

Choose a reason for hiding this comment

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

If it complicates things too much, it might not be worth it.

@youknowriad
Copy link
Contributor

For the unit tests, I actually think we should consider removing all the unit tests that were ported to Core once the patch lands.

@ntsekouras
Copy link
Contributor Author

I added back the gutenberg prefix in get_block_template and get_block_templates as they already exist in core from 5.8 and have been updated for 5.9.

I could see that we have similar handling in other compat like here and many more..

Copy link
Contributor

@youknowriad youknowriad left a comment

Choose a reason for hiding this comment

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

I think this is in a good state already, there are probably a lot more things we can do and we'll discover more issues as we merge the patches.

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.

3 participants