[wp-trac] [WordPress Trac] #60131: Global styles controllers: extend classes with WP_REST_Posts_Controller and WP_REST_Revisions_Controller (was: Global styles revisions controller: extend with WP_REST_Revisions_Controller)

WordPress Trac noreply at wordpress.org
Mon Feb 5 21:45:46 UTC 2024


#60131: Global styles controllers: extend classes with WP_REST_Posts_Controller and
WP_REST_Revisions_Controller
---------------------------------------------+---------------------------
 Reporter:  ramonopoly                       |       Owner:  spacedmonkey
     Type:  enhancement                      |      Status:  assigned
 Priority:  normal                           |   Milestone:  6.5
Component:  REST API                         |     Version:  trunk
 Severity:  normal                           |  Resolution:
 Keywords:  has-patch has-unit-tests commit  |     Focuses:
---------------------------------------------+---------------------------
Description changed by ramonopoly:

Old description:

> The global styles revisions controller was introduced in
> [https://github.com/WordPress/gutenberg/pull/49974
> WordPress/gutenberg#49974].
>
> Originally, global styles revisions were a bit new and had the following
> characteristics:
>
> - Didn't, and still doesn't, return excerpt, content, guid fields
> - Had to do some JSON parsing when preparing the response
>

> Back then, it was more code to override the parent class's functions, and
> I thought having it as a stand alone class left more elbow room for
> subsequent tweaks and changes. Especially since global styles revisions
> were new and evolving.
>
> Now that global styles revisions have "settled", and shares more methods
> with WP_REST_Revisions_Controller, it makes sense to change the base
> class for more consistent interface, less code and less maintenance
> burden.
>
> See discussion:
> [https://github.com/WordPress/gutenberg/pull/55827#discussion_r1399856581
> WordPress/gutenberg#55827 (comment)]

New description:

 As part of the efforts to improve the maintainability of Global Styles
 REST controllers, and to remove a lot of duplicate code we can:

 - extend `WP_REST_Global_Styles_Controller` with
 `WP_REST_Posts_Controller`.
 - extend `WP_REST_Global_Styles_Revisions_Controller` with
 `WP_REST_Revisions_Controller`.



 Originally, global styles were a bit new and had the following
 characteristics:

 - Didn't, and still doesn't, return excerpt, content, guid fields
 - Had to do some JSON parsing when preparing the response

 In other words, the functionality was "special" enough not to warrant
 extending the base controller instead of using WP_REST_Posts_Controller.
 Also, global styles were new and evolving.


 For revisions especially, more code was required to override the parent
 class's functions, and having a stand alone class left more elbow room for
 subsequent tweaks and changes.

 Now that global styles have "settled" however, and shares more methods
 with `WP_REST_Posts_Controller` amd `WP_REST_Revisions_Controller`, it
 makes sense to change the base classes for more consistent interface, less
 code and less maintenance burden.

 See discussion and related PRs:

 -
 [https://github.com/WordPress/gutenberg/pull/55827#discussion_r1399856581
 WordPress/gutenberg#55827 (comment)]
 - [https://github.com/WordPress/gutenberg/pull/49974 Rest API: add
 /revisions endpoint for global styles]
 - [https://github.com/WordPress/gutenberg/pull/35801 Add a Global Styles
 endpoint and use it in the site editor]

--

-- 
Ticket URL: <https://core.trac.wordpress.org/ticket/60131#comment:14>
WordPress Trac <https://core.trac.wordpress.org/>
WordPress publishing platform


More information about the wp-trac mailing list