Skip to content

REST API: Sync sites endpoint with core PR #13055 - #72

Merged
lloc merged 2 commits into
dev/mainfrom
fix/my-sites-exception-removed
Nov 4, 2026
Merged

lloc merged 2 commits into
dev/mainfrom
fix/my-sites-exception-removed

Conversation

@lloc

@lloc lloc commented Nov 2, 2026 •

Copy link
Copy Markdown
Member

Sync wp/v2/sites with WordPress core PR #13055 and harden it

Aligns the RestSitesEndpoint patch with wordpress-develop#13055 (Trac #40365). The controller and the core tests are verbatim copies of the PR branch again.

Changes

  • Access: the endpoint is limited to the main site and users with manage_sites. The "My Sites" exception for members is gone.
  • Main site: it can no longer be archived, spammed, deleted or moved through the API.
  • Atomic writes: site meta is validated before anything is written, so an invalid value no longer leaves a half-created or half-updated site.
  • URLs: home and siteurl move along with a changed domain or path (mapped domains are kept).
  • Paths: new paths follow the Add New Site rule (letters, numbers and hyphens below the network path, lowercased). That rules out encoded characters, dot segments and file names such as wp-login.php or robots.txt. path is required on subdirectory installs.
  • Soft delete: works like "Deactivate" in Network Admin and keeps the site's users.
  • IDs: a body or query id that doesn't match the URL is rejected with 400.

Breaking for API clients

  • Nested paths and paths with dots, underscores, % or non-ASCII characters can no longer be set.
  • A PUT that sends back a path outside the new rule (e.g. one set through Edit Site) fails with 400. Leave path out instead.

Testing

  • npm run test-php-core: 318 tests pass. npm run test-php-unit: 61 tests pass.
  • Black-box run against wp-env: 299 HTTP cases, no high findings.
    Report

Known, not part of this PR

  • The user filter hides archived, spammed and deleted sites (get_blogs_of_user() without $all).

@lloc lloc changed the title Alignment - REST API: Restrict the sites endpoint to the main site an… REST API: Restrict the sites endpoint to the main site and network admins. Nov 2, 2026
@github-actions

github-actions Bot commented Nov 2, 2026

Copy link
Copy Markdown

🔍 WordPress Plugin Check Report

⚠️ Status: Passed with warnings

📊 Report

🎯 Total Issues ❌ Errors ⚠️ Warnings
1 0 1

⚠️ Warnings (1)

📁 modules/SiteActivePlugins/Feature.php (1 warning)
📍 Line 🔖 Check 💬 Message
169 WordPress.NamingConventions.PrefixAllGlobals.DynamicHooknameFound Hook names invoked by a theme/plugin should start with the theme/plugin prefix. Found: "self::FILTER_MAX_SITES".

🤖 Generated by WordPress Plugin Check Action • Learn more about Plugin Check

@lloc lloc changed the title REST API: Restrict the sites endpoint to the main site and network admins. REST API: Sync sites endpoint with core PR #13055 Nov 2, 2026
@lloc
lloc marked this pull request as ready for review November 2, 2026 13:52
@lloc
lloc requested a review from amiut November 2, 2026 13:52

@amiut amiut left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

LGTM, thanks!

@lloc
lloc merged commit 9279c56 into dev/main Nov 4, 2026
7 checks passed
@lloc
lloc deleted the fix/my-sites-exception-removed branch November 4, 2026 11:16
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.

2 participants