Repository navigation
Conversation
|
The following accounts have interacted with this PR and/or linked issues. I will continue to update these lists as activity occurs. Unlinked AccountsThe following contributors have not linked their GitHub and WordPress.org accounts: @jonnydmg. 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: To understand the WordPress project's expectations around crediting contributors, please review the Contributor Attribution page in the Core Handbook. Props Bot commandsYou can trigger Props Bot actions by commenting on this PR:
|
Test using WordPress PlaygroundThe 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
For more details about these limitations and more, check out the Limitations page in the WordPress Playground documentation. |
jonnydmg
left a comment
There was a problem hiding this comment.
There is a big PR to review. Good work getting this ready for core. This code a little old and some things have changed in core, so this PR needs to update accordingly.
Biggest things.
- We need to support sites with
is_site_meta_supportedfalse. There was some work done there to support it but not complete. - Site endpoint needs to be registered on single site. So it always exists then return an error on single site.
- WP_REST_Site_Meta_Fields has no test coverage at all.
- Single site needs tests.
- Super admin should be allowed to do everything on the endpoint.
- Code coverage and ticket need needs to be added to every test.
This feel like we are on the right track, if I am nitpicing here, becuase I think this good to go into core and just want to get the final bits to push forward into core.
I will wait until feedback is complete to do some real testing for this PR.
jonnydmg
left a comment
There was a problem hiding this comment.
There is a big PR to review. Good work getting this ready for core. This code a little old and some things have changed in core, so this PR needs to update accordingly.
Biggest things.
- We need to support sites with
is_site_meta_supportedfalse. There was some work done there to support it but not complete. - Site endpoint needs to be registered on single site. So it always exists then return an error on single site.
- WP_REST_Site_Meta_Fields has no test coverage at all.
- Single site needs tests.
- Super admin should be allowed to do everything on the endpoint.
- Code coverage and ticket need needs to be added to every test.
This feel like we are on the right track, if I am nitpicing here, becuase I think this good to go into core and just want to get the final bits to push forward into core.
I will wait until feedback is complete to do some real testing for this PR.
Introduces WP_REST_Sites_Controller plus tests. See #40365.
aa03545 to
cc81250
Compare
…and add missing group annotations
spacedmonkey
left a comment
There was a problem hiding this comment.
Here is a PR with some unit test improvements.
This is has unit tests that cover single site as well.
…oint-tests Tests: Add unit tests for WP_REST_Site_Meta_Fields functionality
…oint-more-tests Tests: Rename rest-sites-controller.php to wpRestSitesController.php …
Add format validation for the `domain` and `path` parameters in WP_REST_Sites_Controller so malformed values are rejected with a clean 400 rest_invalid_param instead of failing later inside wp_insert_site()/ wp_update_site() (which surfaces as a 500). domain must be a valid hostname or bare IPv4/IPv6 address, optionally followed by a port (bracketed IPv6 is intentionally not supported, so IPv6 addresses can't carry a port). path must start and end with a forward slash and be made up of characters valid in a URL path segment. Ticket #40365.
…t-check-exists' into feature/40365-rest-sites-endpoint-check-exists # Conflicts: # src/wp-includes/rest-api/endpoints/class-wp-rest-sites-controller.php
…oint-force-delete Enhance site deletion process to support force deletion and user removal
…oint-check-exists Check if domain exists before creating / updating.
|
@lloc @peterwilsoncc @JJJ I've opened lloc#12 against Main site only
Permissions
Response and schema
Other
All sites and site meta tests pass on multisite (254) and single site, and lint and PHPStan are clean. Feedback welcome, particularly on:
|
…point-feedback REST API: Main-site-only sites endpoint, tighter response and a single user parameter
|
Pushed a fix for the domain length @spacedmonkey flagged on 09-28.
It's all in one separate commit, so it's easy to revert if you'd rather handle this differently. |
|
@peterwilsoncc @JJJ, could you look at @spacedmonkey's questions in lloc#12? The first one decides whether we keep the "my sites" exception. It's limited to the view context and the current network, but it still works from subsites. If you'd rather require the main site for everything, I'm happy to remove it. |
|
|
For the initial commit I'd like to remove the My Sites allowance and only keep it for the main network (this is where dataviews will be used). The existing My Sites implementation is somewhat flawed in that it allows sub sites to modify it via plugins. It's something that can be solved with the switch to an API endpoint so that should be a goal of the new endpoint. |
|
@peterwilsoncc I've removed the "My Sites" exception as suggested. Every route now needs the main site and Removed:
Only network admins get past the permission check now, so none of these could trigger. Kept:
One behaviour change: a logged-out request to a subsite now gets a 403 ("only from the main site") instead of a 401. The main-site check runs first and doesn't reveal anything about any site. A cross-network "My Sites" API can come later as its own small, read-only endpoint, as @JJJ suggested. |
|
I committed some improvements:
|
|
@peterwilsoncc @spacedmonkey I integrated the REST API endpoints in the MultiSyde plugin and got Claude to test them: inpsyde/multisyde#73 (comment) |
Co-authored-by: Jonny Harris <spacedmonkey@users.noreply.github.com>
spacedmonkey
left a comment
There was a problem hiding this comment.
I don't to avoid more and more round of code review. Let's try and make this the final code review.
| // Flag the site for deletion like Network Admin does. The users stay, so it can be undone. | ||
| /** This action is documented in wp-admin/network/sites.php */ | ||
| do_action( 'deactivate_blog', $blog_id ); | ||
|
|
||
| update_blog_status( $blog_id, 'deleted', '1' ); |
There was a problem hiding this comment.
Please restore the
/** This action is documented in wp-includes/ms-site.php */
do_action_deprecated( 'delete_blog', array( $blog_id, false ), '5.1.0' );
and
/** This action is documented in wp-includes/ms-site.php */
do_action_deprecated( 'deleted_blog', array( $blog_id, false ), '5.1.0' );
These actions were there for a reason, to maintain backwards compatiblity with this
wordpress-develop/src/wp-admin/includes/ms.php
Lines 100 to 120 in 4a96bbd
|
|
||
| $id = (int) $site->blog_id; | ||
|
|
||
| $meta_check = $this->check_meta( $request ); |
There was a problem hiding this comment.
I am not sure about the check pre-flight on checking meta. None of the other endpoints do this. I think we should handle this in another ticket.
|
|
||
| if ( isset( $request['path'] ) ) { | ||
| // Lowercased like Add New Site in Network Admin does. | ||
| $prepared_site['path'] = strtolower( $request['path'] ); |
There was a problem hiding this comment.
Did not know that Add New Site did that, good catch.
Trac ticket: https://core.trac.wordpress.org/ticket/40365
There are some open questions that we should discuss in the trac ticket.