Repository navigation
REST API: Limit the sites endpoint to the current network - #11
Merged
Conversation
Remove cross-network functionality from WP_REST_Sites_Controller: - Drop the `network` and `network_exclude` collection parameters and the `network__in` orderby; collections are always limited to the current network. - Make the `network` schema property read-only, so sites can no longer be created on, or moved to, another network. - Replace check_network_ids() with site_in_network(), filterable via the new `rest_site_in_network` filter ( bool $in_network, WP_Site $site, int $network_id ). - Get, update and delete permission checks return `rest_unable_read_from_network` for a site that is not on the current network, before capability checks. - Simplify check_url_is_available() now that network_id is never supplied. - Remove the network permission tests, add coverage for every CRUD route against a site on a second network and for the filter, and regenerate the API fixture. See #40365. Co-Authored-By: Claude Opus 5.5 <[email protected]>
|
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 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. |
…hecks. The update and delete permission checks now return `rest_unable_update_from_network` and `rest_unable_delete_from_network` respectively, instead of `rest_unable_read_from_network`, for a site that is not on the current network. Tests now assert the code for each operation. See #40365. Co-Authored-By: Claude Opus 5.5 <[email protected]>
The sites endpoint no longer checks super admin status per network, so the `$network_id` parameter added to get_super_admins() and is_super_admin(), and the tests covering it, are no longer needed. Restore both functions and tests/phpunit/tests/user/capabilities.php to their trunk versions. See #40365. Co-Authored-By: Claude Opus 5.5 <[email protected]>
lloc
approved these changes
Oct 5, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Trac ticket: https://core.trac.wordpress.org/ticket/40365
Summary
Removes cross-network functionality from
WP_REST_Sites_Controller, so the endpoint only operates on the current network.Collection: the
network/network_excludequery params and thenetwork__inorderby are removed. Results are always limited to the current network, and anetworkparam is ignored.Schema:
networkis nowreadonly. Sites cannot be created on, or moved to, another network; new sites always land on the current network.Permissions:
check_network_ids()is replaced withsite_in_network( WP_Site $site ). Each single-site permission check returns its own error (401/403) for a site that is not on the current network. This runs before the capability checks, so it applies to super admins too.get_item_permissions_checkrest_unable_read_from_networkupdate_item_permissions_checkrest_unable_update_from_networkdelete_item_permissions_checkrest_unable_delete_from_networkNew filter:
rest_site_in_network( bool $in_network, WP_Site $site, int $network_id )lets the result be overridden.check_url_is_available()is simplified now thatnetwork_idis never supplied by the request.Super admin changes reverted: the
$network_idparameter added toget_super_admins()andis_super_admin()is no longer needed. Both functions, andtests/phpunit/tests/user/capabilities.php, are restored to their trunk versions.Tests
Removed the tests for the old network params and per-network super admin checks.
Added coverage for every CRUD route against a site on a second network:
includeon the collectionnetworkEach case asserts the error code for its operation.
Added tests for the filter: allowing a site on another network, blocking one on the current network, and the arguments it receives.
Regenerated
tests/qunit/fixtures/wp-api-generated.js.Verification
restapigroup has one pre-existing, unrelated failure:Test_oEmbed_Controller::test_proxy_with_classic_embed_provider. It also fails in isolation.🤖 Generated with Claude Code