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/global styles revision extends revisions controller #6105

Conversation

spacedmonkey
Copy link
Member

@spacedmonkey spacedmonkey commented Feb 13, 2024

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


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.

ramonjd and others added 17 commits February 7, 2024 12:49
WP_REST_Global_Styles_Revisions_Controller extends WP_REST_Controller
…-revisions-controller.php

Co-authored-by: Mukesh Panchal <mukeshpanchal27@users.noreply.github.com>
Excluding order and order by from the collection query params

Comment
Updating generated API file
removing __construct, get_item and update_item in favour of the parent class methods

Add $allow_batch property, setting it to false
Co-authored-by: Jonny Harris <148061917+jonnynews@users.noreply.github.com>
Copy link

github-actions bot commented Feb 13, 2024

The following accounts have interacted with this PR and/or linked issues. I will continue to update these lists as activity occurs. You can also manually ask me to refresh this list by adding the props-bot label.

Unlinked Accounts

The following contributors have not linked their GitHub and WordPress.org accounts: @jonnynews.

Contributors, please read how to link your accounts to ensure your work is properly credited in WordPress releases.

Core Committers: Use this line as a base for the props when committing in SVN:

Props ramonopoly, spacedmonkey, swissspidy.

To understand the WordPress project's expectations around crediting contributors, please review the Contributor Attribution page in the Core Handbook.

Copy link

Test using WordPress Playground

The changes in this pull request can previewed and tested using a WordPress Playground instance.

WordPress Playground is an experimental project that creates a full WordPress instance entirely within the browser.

Some things to be aware of

  • The Plugin and Theme Directories cannot be accessed within Playground.
  • All changes will be lost when closing a tab with a Playground instance.
  • All changes will be lost when refreshing the page.
  • A fresh instance is created each time the link below is clicked.
  • Every time this pull request is updated, a new ZIP file containing all changes is created. If changes are not reflected in the Playground instance,
    it's possible that the most recent build failed, or has not completed. Check the list of workflow runs to be sure.

For more details about these limitations and more, check out the Limitations page in the WordPress Playground documentation.

Test this pull request with WordPress Playground.

@spacedmonkey
Copy link
Member Author

Committed

@spacedmonkey spacedmonkey deleted the update/global-styles-revision-extends-revisions-controller branch February 13, 2024 14:33
@spacedmonkey spacedmonkey restored the update/global-styles-revision-extends-revisions-controller branch February 13, 2024 15:38
@spacedmonkey spacedmonkey reopened this Feb 13, 2024
@spacedmonkey
Copy link
Member Author

@getdave @ramonjd @swissspidy Can you take a look at this PR.

This fix 95db1e9 make the e2e test pass. But I would love your thoughts on this PR.

spacedmonkey and others added 2 commits February 13, 2024 20:46
This commit adds the 'allow_batch' option to several API endpoints in the WordPress API generated tests fixture. The 'allow_batch' option has been set to false for version 1, effectively disabling batch requests for these endpoints, as a safety measure.
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 appreciate the quick handling, and for the constant help in getting this change in.

$this->namespace = 'wp/v2';
$this->rest_base = 'global-styles';
$this->post_type = 'wp_global_styles';
public function __construct( $post_type = 'wp_global_styles' ) {
Copy link
Member

Choose a reason for hiding this comment

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

This LGTM. I've tested with the plugin activated (with and without this change).

It also provides backwards compatibility for folks running older versions of Gutenberg.

If folks think it's appropriate I can update the class instantiation in Gutenberg to pass 'wp_global_styles' as well, to make things more consistent. But this PR's changes make that unnecessary I suppose.

https://github.com/WordPress/gutenberg/blob/b35bc15f13e2287befaa638a3a6aa168c31b5362/lib/compat/wordpress-6.5/rest-api.php#L17-L17

@WordPress WordPress deleted a comment from ak10512106 Feb 19, 2024
ramonjd added a commit to ramonjd/wordpress-develop that referenced this pull request May 18, 2024
Bumped version from 6.5 to 6.6 in annotations
Various code documentation version annotations have been updated from 6.5.0 to 6.6.0. This includes adjustments in class-wp-post-type.php and the REST endpoints for global styles and global styles revisions. These changes document accurately in which version these alterations were introduced.
The commit transforms multiple unset function calls into single line statements in the WP Rest Global Styles Revisions Controller. This aims to enhance code readability and maintainability, without changing functionality.
@spacedmonkey
Copy link
Member Author

@swissspidy Do you mind doing a review of this PR. I like think this PR is ready to commit.

The commit disables the autosave endpoints for the global styles in WordPress. Modifications were made to both post.php and class-wp-post-type.php to prevent autosave for the 'wp_global_styles' post type. This ensures that global Styles does not trigger unnecessary autosaves.
This commit removes a comment line in the class-wp-post-type.php file. The deleted comment was linked to the autosave instantiation for the 'wp_global_styles' post types, which is no longer relevant within the current context.
Comment on lines +490 to +491
// Disable autosave endpoints for global styles.
'autosave_rest_controller_class' => 'stdClass',
Copy link
Member

Choose a reason for hiding this comment

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

Instead of doing this, add remove_post_type_support( 'wp_global_styles', 'autosave' ) below.

ramonjd added a commit to ramonjd/wordpress-develop that referenced this pull request May 28, 2024
Bumped version from 6.5 to 6.6 in annotations
@swissspidy
Copy link
Member

Closing in favor of #6573 so we can finalize the patch there.

@swissspidy swissspidy closed this May 28, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
4 participants