Repository navigation
Fix failed tests - #73
Conversation
…d network admins.
Signed-off-by: Dennis Ploetner <re@lloc.de>
🔍 WordPress Plugin Check Report
📊 Report
|
| 📍 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
REST API Test Report:
|
| Test cases | 352 (313 scripted + 39 sequence/side-effect checks) |
| ✅ as expected | 327 |
| 19, grouped into 5 findings | |
| ℹ️ noted | 6 |
| 🔴 High | 0 |
| 🟠 Medium | 2 (M1 new, fixed; M2 = run 8 M3, open) |
| 🟡 Low | 1 (L3 new, fixed) |
| ℹ️ regraded | L1, L2 (same behavior as core) |
The main point: all four fixes from stash@{0} hold in the committed code (H1, M1, M2 and L3 from run 8 are closed). There is one new bypass in the stricter path check: is_valid_path() anchors with $, which in PCRE also matches before a trailing newline, so "/name/\n" passes. That path skips the duplicate check, and a PUT with it makes an existing site unreachable (M1). Run 8's M3 (the user filter), L1 and L2 are unchanged.
Changes since run 8
| Item | Run 8 (9279c56) |
Run 9 (e2feea2) |
|---|---|---|
| Soft delete keeps site members | ✅ admin and bbsub are still members after DELETE, after a repeated DELETE and after the undelete | |
id in the body or query must match the URL |
✅ 400 rest_site_id_mismatch on GET/HEAD/PUT/PATCH/POST/DELETE (+force), for body and query, string and float ids; "355" and 355.0 count as a match |
|
Path limited to [a-z0-9-]+ |
✅ all 18 run 8 paths are rejected, plus raw UTF-8, tab, NUL, leading newline, 300-char and all reserved names; |
|
| Path lowercased | ✅ POST and PUT; home/siteurl follow |
|
user filter hides archived/spam/deleted sites |
||
| Domains not normalized | ℹ️ L1 | |
| Negative / out-of-range integers | ℹ️ L2 | |
POST without path |
400 rest_site_taken |
400 rest_missing_callback_param (path is required now) |
POST without domain |
not tested | rest_invalid_param although the schema says optional with default "" (new L3) |
| Reads only for super admins on the main site | ✅ | ✅ 30/30 |
| Main-site guard | ✅ | ✅ 19/19, network healthy after every request |
Fixes applied after the run
| Finding | Change | Verified |
|---|---|---|
| M1 | is_valid_path() :1270: /$# → /$#D, so $ no longer matches before a trailing newline |
POST "/r1106-fix-nl/\n" → 400; PUT /355 {"path":"/r1106-s2/\n"} → 400; new data row trailing newline |
| L3 | domain schema :1431: 'default' => '' → 'required' => true (core applies required to CREATABLE only) |
POST without domain → 400 rest_missing_callback_param (params: domain); PUT without domain → 200; new test_create_item_requires_domain |
npm run test-php-core 305 OK, npm run test-php-unit 61 OK, PHPStan and PHPCS clean.
Findings
M1. 🟠 MEDIUM (✅ fixed in the working tree): a path with a trailing newline passes validation, skips the duplicate check and makes sites unreachable (new)
Repro:
POST /sites {"domain":"localhost:8888","path":"/r1106-nl1/\n"}→ 201, id 365.wp_blogs.path=2F72313130362D6E6C312F0A2F="/r1106-nl1/\n/";home/siteurl=http://localhost:8888/r1106-nl1.POST /sites {"domain":"localhost:8888","path":"/r1106-nl1/"}→ 201, id 392. Two sites now claim the same URL.get_site_by_path()resolves/r1106-nl1/to 392, so site 365 can't be reached, although itshomepoints there.PUT /sites/355 {"path":"/r1106-s2/\n"}→ 200. The path of s2 becomes"/r1106-s2/\n/", its front end at/r1106-s2/answers 404, and the URL is free for another site. Restored withPUT {"path":"/r1106-s2/"}.- Rejected (✅): leading newline, tab, NUL,
"/\n"on the main site,"/wp-json/\n"-style reserved names (the reserved check still seeswp-json).
Cause: is_valid_path() :1270 uses '#^' . $base . '([a-z0-9-]+)/$#'. Without the D modifier, $ matches before a final \n. prepare_item_for_database() :1083 then stores strtolower( $request['path'] ) with the newline, and wp_insert_site()/wp_update_site() add the trailing slash after it. check_url_is_available() :1312 compares the newline path, so it finds no duplicate.
Impact: only super admins can trigger it, but a single PUT (from a client that doesn't trim input, for example) takes a site offline and hands its URL to the next site that is created there. Nothing in Network Admin shows the control character. It's the same class of problem the strict path check was written to close.
Fix: '#^' . $base . '([a-z0-9-]+)/\z#' (or the D modifier). The same anchor is in is_valid_domain() :1178, :1193 and :1209. Domains are saved by core's preg_replace('/[^a-z0-9\-.:]+/i', ''), which strips the newline (verified: "r1106.test\n" is stored as r1106.test), so only the path is exploitable. Add a test with "/name/\n" to wpRestSitesController.php.
M2. 🟠 MEDIUM: the user filter drops archived, spammed and deleted sites (run 8: M3, unchanged)
Repro: GET /sites?user=3&search=r1106-s → [354,355,356]. After PUT /354 {"archived":true}, PUT /355 {"spam":true} and PUT /356 {"deleted":true}:
?user=3→[]?user=3&archived=true→[](expected[354])?user=3&spam=true→[](expected[355])?user=3&deleted=true→[](expected[356])- the same without
user→[354,355,356]
Cause: get_user_site_ids() :441 calls get_blogs_of_user( (int) $user_id ) without $all = true.
Impact: a "sites of user X" view silently hides the sites that need attention, and user combined with a status filter always returns an empty list.
Fix: get_blogs_of_user( (int) $user_id, true ).
L1. ℹ️ INFO (regraded, same as core): domains are not normalized or checked for plausibility (unchanged)
Repro: POST /sites → 201 for R1106-Up.Example.Test (stored in upper case), localhost:08888, ::1, 999.999.999.999, 123.
Cause: is_valid_domain() :1148 checks the character set, the length and the port range, but not the IP structure, and doesn't lowercase.
Core: Network Admin's Edit Site (site-info.php) takes the host from parse_url() without lowercasing or an IP check, and wp_prepare_site_data() (ms-site.php:527) only strips characters outside [a-z0-9\-.:]. The endpoint matches core.
Impact: the sites can't be reached. Scheme, path, space, underscore, leading hyphen, trailing dot, port 0/70000 and 254 characters are all rejected (✅).
L2. ℹ️ INFO (regraded, same as core): negative and out-of-range integers are accepted (unchanged)
Repro: GET ?offset=-1&per_page=1 → 200 (one site); GET ?include=-1 → 200 with site 1; GET ?lang_id=-1 → 200 []; POST {"lang_id":-5} → 201, stored as -5; POST {"lang_id":2147483648} → 201, stored as 2147483647; PUT {"lang_id":-1} → 200.
Cause: offset and the lang_id schema have no minimum/maximum.
Core: the core posts, comments and users controllers have no minimum on offset either; WP_Site_Query and wp_parse_id_list() apply absint(); wp_insert_site() doesn't validate lang_id (signed int(11), "currently unused"). The endpoint matches core.
Impact: confusing results only.
L3. 🟡 LOW (✅ fixed in the working tree): domain is effectively required, but the schema says it's optional with default "" (new)
Repro: POST /sites {"path":"/r1106-nodom/"} → 400 rest_invalid_param "Invalid parameter(s): domain"; the same with "domain":"". OPTIONS /sites lists domain with required: false, default: "".
Cause: the schema default '' (:1431) is validated like a sent value, and validate_domain() :1118 rejects it. check_url_is_available() :1291 also falls back to '' for a new site.
Impact: the documented default can never succeed, and the error doesn't say the field is missing. Clients have to send the domain even on a subdirectory install, where it is always the network domain.
Fix: either do what was done for path at :59–63 (unset the default, required => true), or default to get_network()->domain on creation.
ℹ️ Info
- I1: the main site can still be set to
matureorpublic:false(200). Neither takes the network down; both were restored right away. - I2: a mismatched
idreturns 400rest_site_id_mismatcheven to anonymous users and members, before 401/403, because core validates args before it callspermission_callback. Nothing leaks beyond the mismatch itself. - I3:
GET ?page=9999returns 200[]. The posts controller returns 400rest_post_invalid_page_number; the comments controller behaves like this one. - I4:
GET ?user=999999(nonexistent user) returns 200[], whilePOST {"user":999999}returns 400. - I5: the path
/-/is accepted (201). Network Admin's Add New Site allows it too ([a-zA-Z0-9-]+). - I6:
meta.rest_test_array: "abc"is accepted and stored as["abc"]. That's core's list coercion fortype: array. - Other: every read denial uses the code
rest_forbidden_context.blogname,user,siteurlandnetworkon PUT are silently ignored. A repeated soft delete returns 200./batch/v1is not allowed for this route.
Side effects verified
POST
- No 400 left a site behind (spot-checked by path for every rejected path/domain/meta case).
- Meta of all types is stored correctly, both values of the multi key included;
rest_test_hidden, unregistered keys andnullcreate no rows. /R1106-Upper/is stored as/r1106-upper/.
PUT/PATCH
- Each flag toggled its own column, and all were back to 0 afterwards.
blogname,user,siteurlandnetworkstayed unchanged. - s2 meta after the sequence:
rest_test_integer=3,rest_test_multi=x;nulldeletedrest_test_string. No hidden or unregistered rows. Invalid meta together with a flag or path → 400, nothing changed. - id mismatch: 354, 358 and 359 were untouched by every mismatched request.
DELETE
- Soft delete of 356:
deleted=1, admin and bbsub still members; repeat → 200;PUT {"deleted":false}→deleted=0, both members still there. - Force delete of 357 and 358: rows, blogmeta,
wp_N_capabilitiesusermeta and allwp_N_*tables gone; GET/PUT → 404.
Main site: after each of the 19 requests the front end and API answered 200. Final row 1: localhost:8888 /, public=1, all flags 0.
Test matrices
Path and domain moves (9 cases, 9 ✅)
| Test case | Request | Expected | Actual | Result |
|---|---|---|---|---|
| path move | PUT /sites/355 {"path":"/r1106-s2-moved/"} |
home/siteurl follow | 200, both http://localhost:8888/r1106-s2-moved |
✅ |
| domain move | PUT /sites/355 {"domain":"r1106-s2.example.test"} |
follow | 200, http://r1106-s2.example.test/r1106-s2-moved |
✅ |
| both | PUT /sites/355 {"domain":"r1106-s2b.example.test","path":"/r1106-s2b/"} |
follow | 200, http://r1106-s2b.example.test/r1106-s2b |
✅ |
| back | PUT /sites/355 {"domain":"localhost:8888","path":"/r1106-s2/"} |
restored | 200, http://localhost:8888/r1106-s2 |
✅ |
| mapped home, path move | home = https://mapped.r1106.test, PUT {"path":"/r1106-s2-m2/"} |
home kept, siteurl follows | 200, home kept, siteurl …/r1106-s2-m2 |
✅ |
| mapped home, move back | PUT {"path":"/r1106-s2/"} |
home kept | 200 | ✅ |
| https scheme, move | home/siteurl https://localhost:8888/r1106-s2, PUT {"path":"/r1106-s2-https/"} |
scheme kept | 200, both https://…/r1106-s2-https |
✅ |
| uppercase PUT | PUT {"path":"/R1106-S2-Up/"} |
lowercased | 200, /r1106-s2-up/, home/siteurl lower case |
✅ |
| uppercase back | PUT {"path":"/r1106-s2/"} |
200 | 200 | ✅ |
user filter with status flags (6 cases, 2 ✅)
| Test case | Request | Expected | Actual | Result |
|---|---|---|---|---|
| baseline | GET /sites?user=3&search=r1106-s |
[354,355,356] | [354,355,356] | ✅ |
| after flags | GET /sites?user=3&search=r1106-s |
[354,355,356] | [] | |
| + archived | GET /sites?user=3&archived=true&search=r1106-s |
[354] | [] | |
| + spam | GET /sites?user=3&spam=true&search=r1106-s |
[355] | [] | |
| + deleted | GET /sites?user=3&deleted=true&search=r1106-s |
[356] | [] | |
| no user | GET /sites?search=r1106-s&include=354,355,356 |
[354,355,356] | [354,355,356] | ✅ |
Soft delete keeps members (5 cases, 5 ✅)
| Test case | Request | Expected | Actual | Result |
|---|---|---|---|---|
| members before | wp user list --url=…/r1106-s3/ |
admin, bbsub | admin (administrator), bbsub (editor) | ✅ |
| soft delete | DELETE /sites/356 |
200, deleted=1 | 200 deleted:true, wp_blogs.deleted=1 |
✅ |
| members after | wp user list |
unchanged | admin, bbsub | ✅ |
| repeat soft delete | DELETE /sites/356 |
200 | 200 | ✅ |
| undelete | PUT /sites/356 {"deleted":false} |
200, members kept | 200, deleted=0, admin and bbsub |
✅ |
Main site, run last (19 cases, 19 ✅)
| Test case | Request | Expected | Actual | Result |
|---|---|---|---|---|
| archived | PUT /sites/1 {"archived":true} |
403 | 403 rest_cannot_edit_main_site | ✅ |
| spam | PUT /sites/1 {"spam":true} |
403 | 403 rest_cannot_edit_main_site | ✅ |
| deleted | PUT /sites/1 {"deleted":true} |
403 | 403 rest_cannot_edit_main_site | ✅ |
| path | PUT /sites/1 {"path":"/r1106-main/"} |
403 | 403 rest_cannot_edit_main_site | ✅ |
| domain | PUT /sites/1 {"domain":"r1106-main.test"} |
403 | 403 rest_cannot_edit_main_site | ✅ |
| PATCH archived | PATCH /sites/1 {"archived":true} |
403 | 403 rest_cannot_edit_main_site | ✅ |
| POST archived | POST /sites/1 {"archived":true} |
403 | 403 rest_cannot_edit_main_site | ✅ |
| archived false (no-op) | PUT /sites/1 {"archived":false} |
200 | 200 | ✅ |
| path newline | PUT /sites/1 {"path":"/\n"} |
400 | 400 rest_invalid_param | ✅ |
path same / |
PUT /sites/1 {"path":"/"} |
200 | 200 | ✅ |
| soft delete | DELETE /sites/1 |
403 | 403 rest_cannot_delete_main_site | ✅ |
| force delete | DELETE /sites/1?force=true |
403 | 403 rest_cannot_delete_main_site | ✅ |
| via query id | PUT /sites/354?id=1 {"archived":true} |
400 | 400 rest_site_id_mismatch | ✅ |
| mature | PUT /sites/1 {"mature":true} |
200 (I1) | 200 | ✅ |
| mature restore | PUT /sites/1 {"mature":false} |
200 | 200 | ✅ |
| public false | PUT /sites/1 {"public":false} |
200 (I1) | 200 | ✅ |
| public restore | PUT /sites/1 {"public":true} |
200 | 200 | ✅ |
| batch | POST /batch/v1 with PUT /wp/v2/sites/1 {"archived":true} |
rejected | rest_batch_not_allowed | ✅ |
path /wp-json/ |
POST /sites {"domain":"localhost:8888","path":"/wp-json/"} |
400 | 400 | ✅ |
Permissions (30 cases, 30 ✅)
| Test case | Request | Auth | Expected | Actual | Result |
|---|---|---|---|---|---|
| list, anonymous | GET /sites |
anon | 401 | 401 rest_forbidden_context | ✅ |
| HEAD list, anonymous | HEAD /sites |
anon | 401 | 401 (no body) | ✅ |
| item, anonymous | GET /sites/354 |
anon | 401 | 401 rest_forbidden_context | ✅ |
| nonexistent item, anonymous | GET /sites/999999 |
anon | 401 | 401 rest_forbidden_context | ✅ |
| own sites, anonymous | GET /sites?user=me |
anon | 401 | 401 rest_forbidden_context | ✅ |
| create, anonymous | POST /sites {"domain":"localhost:8888","path":"/r1106-anon/"} |
anon | 401 | 401 rest_cannot_create | ✅ |
| update, anonymous | PUT /sites/354 {"public":false} |
anon | 401 | 401 rest_cannot_edit | ✅ |
| delete, anonymous | DELETE /sites/354 |
anon | 401 | 401 rest_cannot_delete | ✅ |
| list, member | GET /sites |
bb | 403 | 403 rest_forbidden_context | ✅ |
| own sites, member | GET /sites?user=me |
bb | 403 | 403 rest_forbidden_context | ✅ |
| own sites by ID, member | GET /sites?user=3 |
bb | 403 | 403 rest_forbidden_context | ✅ |
| own site, member | GET /sites/354 |
bb | 403 | 403 rest_forbidden_context | ✅ |
| foreign site, member | GET /sites/357 |
bb | 403 | 403 rest_forbidden_context | ✅ |
| nonexistent site, member | GET /sites/999999 |
bb | 403 | 403 rest_forbidden_context | ✅ |
| embed context, member | GET /sites/354?context=embed |
bb | 403 | 403 rest_forbidden_context | ✅ |
| edit context, member | GET /sites/354?context=edit |
bb | 403 | 403 rest_forbidden_context | ✅ |
| filter archived, member | GET /sites?archived=true |
bb | 403 | 403 rest_forbidden_context | ✅ |
| create, member | POST /sites {"domain":"localhost:8888","path":"/r1106-bb/"} |
bb | 403 | 403 rest_cannot_create | ✅ |
| update own site, member | PUT /sites/354 {"public":false} |
bb | 403 | 403 rest_cannot_edit | ✅ |
| delete own site, member | DELETE /sites/354 |
bb | 403 | 403 rest_cannot_delete | ✅ |
| force delete, member | DELETE /sites/354?force=true |
bb | 403 | 403 rest_cannot_delete | ✅ |
| own sites via subsite, member | GET /r1106-s1/wp-json/wp/v2/sites?user=me |
bb | 403 | 403 rest_cannot_view_not_on_main_site | ✅ |
| list via subsite, super admin | GET /r1106-s1/wp-json/wp/v2/sites |
admin | 403 | 403 rest_cannot_view_not_on_main_site | ✅ |
| item via subsite, super admin | GET /r1106-s1/wp-json/wp/v2/sites/355 |
admin | 403 | 403 rest_cannot_view_not_on_main_site | ✅ |
| create via subsite, super admin | POST /r1106-s1/wp-json/wp/v2/sites {"domain":"localhost:8888","path":"/r1106-viasub/"} |
admin | 403 | 403 rest_cannot_create_not_on_main_site | ✅ |
| update via subsite, super admin | PUT /r1106-s1/wp-json/wp/v2/sites/355 {"lang_id":0} |
admin | 403 | 403 rest_cannot_edit_not_on_main_site | ✅ |
| delete via subsite, super admin | DELETE /r1106-s1/wp-json/wp/v2/sites/358 |
admin | 403 | 403 rest_cannot_delete_not_on_main_site | ✅ |
| list, super admin | GET /sites |
admin | 200 | 200 10 items: 1,2,3,6,7,8,9,10 total=269 | ✅ |
| item, super admin | GET /sites/354 |
admin | 200 | 200 id=354 localhost:8888/r1106-s1/ | ✅ |
| rest_route fallback, anonymous | GET /?rest_route=/wp/v2/sites |
anon | 401 | 401 rest_forbidden_context | ✅ |
GET /sites (collection) (81 cases, 76 ✅)
| Test case | Request | Auth | Expected | Actual | Result |
|---|---|---|---|---|---|
| default | GET /sites |
admin | 200 | 200 10 items: 1,2,3,6,7,8,9,10 total=269 | ✅ |
| HEAD | HEAD /sites |
admin | 200 | 200 (no body) | ✅ |
| context=view | GET /sites?context=view |
admin | 200 | 200 10 items: 1,2,3,6,7,8,9,10 total=269 | ✅ |
| context=embed | GET /sites?context=embed |
admin | 200 | 200 10 items: 1,2,3,6,7,8,9,10 total=269 | ✅ |
| context=edit | GET /sites?context=edit |
admin | 200 | 200 10 items: 1,2,3,6,7,8,9,10 total=269 | ✅ |
| context invalid | GET /sites?context=foo |
admin | 400 | 400 rest_invalid_param (rest_not_in_enum) | ✅ |
| context array | GET /sites?context[]=view |
admin | 400 | 400 rest_invalid_param (rest_invalid_type) | ✅ |
| page=1 | GET /sites?page=1&per_page=2 |
admin | 200 | 200 2 items: 1,2 total=269 | ✅ |
| page=2 | GET /sites?page=2&per_page=2 |
admin | 200 | 200 2 items: 3,6 total=269 | ✅ |
| page=0 | GET /sites?page=0 |
admin | 400 | 400 rest_invalid_param (rest_out_of_bounds) | ✅ |
| page=-1 | GET /sites?page=-1 |
admin | 400 | 400 rest_invalid_param (rest_out_of_bounds) | ✅ |
| page=abc | GET /sites?page=abc |
admin | 400 | 400 rest_invalid_param (rest_invalid_type) | ✅ |
| page=1.5 | GET /sites?page=1.5 |
admin | 400 | 400 rest_invalid_param (rest_invalid_type) | ✅ |
| page beyond last | GET /sites?page=9999 |
admin | 400 | 200 0 items: total=269 | ℹ️ I3 |
| per_page=1 | GET /sites?per_page=1 |
admin | 200 | 200 1 items: 1 total=269 | ✅ |
| per_page=100 | GET /sites?per_page=100 |
admin | 200 | 200 100 items: 1,2,3,6,7,8,9,10 total=269 | ✅ |
| per_page=0 | GET /sites?per_page=0 |
admin | 400 | 400 rest_invalid_param (rest_out_of_bounds) | ✅ |
| per_page=101 | GET /sites?per_page=101 |
admin | 400 | 400 rest_invalid_param (rest_out_of_bounds) | ✅ |
| per_page=-1 | GET /sites?per_page=-1 |
admin | 400 | 400 rest_invalid_param (rest_out_of_bounds) | ✅ |
| per_page=abc | GET /sites?per_page=abc |
admin | 400 | 400 rest_invalid_param (rest_invalid_type) | ✅ |
| per_page=2.5 | GET /sites?per_page=2.5 |
admin | 400 | 400 rest_invalid_param (rest_invalid_type) | ✅ |
| offset=0 | GET /sites?offset=0&per_page=1 |
admin | 200 | 200 1 items: 1 total=269 | ✅ |
| offset=2 | GET /sites?offset=2&per_page=1 |
admin | 200 | 200 1 items: 3 total=269 | ✅ |
| offset=-1 | GET /sites?offset=-1&per_page=1 |
admin | 400 | 200 1 items: 2 total=269 | ℹ️ L2 |
| offset=abc | GET /sites?offset=abc |
admin | 400 | 400 rest_invalid_param (rest_invalid_type) | ✅ |
| search | GET /sites?search=r1106-s |
admin | 200 | 200 4 items: 354,355,356,357 total=4 | ✅ |
| search no hit | GET /sites?search=zzznohit |
admin | 200 | 200 0 items: total=0 | ✅ |
| search wildcard * | GET /sites?search=r1106-s* |
admin | 200 | 200 4 items: 354,355,356,357 total=4 | ✅ |
| search SQL quote | GET /sites?search=%27%20OR%201%3D1-- |
admin | 200 | 200 0 items: total=0 | ✅ |
| search percent | GET /sites?search=%25 |
admin | 200 | 200 5 items: 87,88,192,201,247 total=5 | ✅ |
| search array | GET /sites?search[]=x |
admin | 400 | 400 rest_invalid_param (rest_invalid_type) | ✅ |
| domain | GET /sites?domain=localhost:8888&per_page=1 |
admin | 200 | 200 1 items: 1 total=225 | ✅ |
| domain no hit | GET /sites?domain=nohit.test |
admin | 200 | 200 0 items: total=0 | ✅ |
| domain_exclude | GET /sites?domain_exclude=localhost:8888 |
admin | 200 | 200 10 items: 8,31,60,62,68,108,109,110 total=44 | ✅ |
| path | GET /sites?path=/r1106-s1/ |
admin | 200 | 200 1 items: 354 total=1 | ✅ |
| path multiple | GET /sites?path[]=/r1106-s1/&path[]=/r1106-s2/ |
admin | 200 | 200 2 items: 354,355 total=2 | ✅ |
| path_exclude | GET /sites?path_exclude=/r1106-s1/&search=r1106-s |
admin | 200 | 200 3 items: 355,356,357 total=3 | ✅ |
| include | GET /sites?include=354,355 |
admin | 200 | 200 2 items: 354,355 total=2 | ✅ |
| include non-numeric | GET /sites?include=abc |
admin | 400 | 400 rest_invalid_param (rest_invalid_type) | ✅ |
| include float | GET /sites?include=1.5 |
admin | 400 | 400 rest_invalid_param (rest_invalid_type) | ✅ |
| include -1 | GET /sites?include=-1 |
admin | 400 | 200 1 items: 1 total=1 | ℹ️ L2 |
| exclude | GET /sites?exclude=354&search=r1106-s |
admin | 200 | 200 3 items: 355,356,357 total=3 | ✅ |
| exclude non-numeric | GET /sites?exclude=abc |
admin | 400 | 400 rest_invalid_param (rest_invalid_type) | ✅ |
| order desc | GET /sites?order=desc&per_page=2 |
admin | 200 | 200 2 items: 361,360 total=269 | ✅ |
| order invalid | GET /sites?order=up |
admin | 400 | 400 rest_invalid_param (rest_not_in_enum) | ✅ |
| orderby domain | GET /sites?orderby=domain&per_page=2 |
admin | 200 | 200 2 items: 256,295 total=269 | ✅ |
| orderby path | GET /sites?orderby=path&per_page=2 |
admin | 200 | 200 2 items: 1,275 total=269 | ✅ |
| orderby registered | GET /sites?orderby=registered&per_page=2 |
admin | 200 | 200 2 items: 1,2 total=269 | ✅ |
| orderby last_updated | GET /sites?orderby=last_updated&per_page=2 |
admin | 200 | 200 2 items: 3,2 total=269 | ✅ |
| orderby domain_length | GET /sites?orderby=domain_length&per_page=2 |
admin | 200 | 200 2 items: 111,112 total=269 | ✅ |
| orderby path_length | GET /sites?orderby=path_length&per_page=2 |
admin | 200 | 200 2 items: 1,275 total=269 | ✅ |
| orderby network_id | GET /sites?orderby=network_id&per_page=2 |
admin | 200 | 200 2 items: 1,2 total=269 | ✅ |
| orderby site__in | GET /sites?orderby=site__in&include=355,354 |
admin | 200 | 200 2 items: 355,354 total=2 | ✅ |
| orderby invalid | GET /sites?orderby=blogname |
admin | 400 | 400 rest_invalid_param (rest_not_in_enum) | ✅ |
| user=me | GET /sites?user=me |
admin | 200 | 200 10 items: 1,8,9,31,32,58,59,60 total=45 | ✅ |
| user=3 | GET /sites?user=3&search=r1106-s |
admin | 200 | 200 3 items: 354,355,356 total=3 | ✅ |
| user nonexistent | GET /sites?user=999999 |
admin | 400 | 200 0 items: total=0 | ℹ️ I4 |
| user 0 | GET /sites?user=0 |
admin | 400 | 400 rest_invalid_param (rest_no_matching_schema) | ✅ |
| user -1 | GET /sites?user=-1 |
admin | 400 | 400 rest_invalid_param (rest_no_matching_schema) | ✅ |
| user string | GET /sites?user=bbsub |
admin | 400 | 400 rest_invalid_param (rest_no_matching_schema) | ✅ |
| public=true | GET /sites?public=true&per_page=1 |
admin | 200 | 200 1 items: 1 total=255 | ✅ |
| public=false | GET /sites?public=false |
admin | 200 | 200 10 items: 6,10,18,29,63,97,121,138 total=14 | ✅ |
| public=maybe | GET /sites?public=maybe |
admin | 400 | 400 rest_invalid_param (rest_invalid_type) | ✅ |
| archived=true | GET /sites?archived=true |
admin | 200 | 200 10 items: 2,6,15,29,63,97,138,240 total=11 | ✅ |
| archived=2 | GET /sites?archived=2 |
admin | 400 | 400 rest_invalid_param (rest_invalid_type) | ✅ |
| mature=true | GET /sites?mature=true |
admin | 200 | 200 10 items: 2,6,29,63,97,129,138,266 total=10 | ✅ |
| mature=x | GET /sites?mature=x |
admin | 400 | 400 rest_invalid_param (rest_invalid_type) | ✅ |
| spam=true | GET /sites?spam=true |
admin | 200 | 200 9 items: 2,6,29,63,97,138,266,302 total=9 | ✅ |
| spam=x | GET /sites?spam=x |
admin | 400 | 400 rest_invalid_param (rest_invalid_type) | ✅ |
| deleted=true | GET /sites?deleted=true |
admin | 200 | 200 10 items: 7,16,30,36,63,93,97,138 total=11 | ✅ |
| deleted=x | GET /sites?deleted=x |
admin | 400 | 400 rest_invalid_param (rest_invalid_type) | ✅ |
| lang_id=0 | GET /sites?lang_id=0&per_page=1 |
admin | 200 | 200 1 items: 1 total=242 | ✅ |
| lang_id=-1 | GET /sites?lang_id=-1 |
admin | 400 | 200 0 items: total=0 | ℹ️ L2 |
| lang_id=abc | GET /sites?lang_id=abc |
admin | 400 | 400 rest_invalid_param (rest_invalid_type) | ✅ |
| lang_id_exclude=0 | GET /sites?lang_id_exclude=0 |
admin | 200 | 200 10 items: 6,17,29,37,63,71,97,118 total=27 | ✅ |
| lang_id_exclude=abc | GET /sites?lang_id_exclude=abc |
admin | 400 | 400 rest_invalid_param (rest_invalid_type) | ✅ |
| before ISO | GET /sites?before=2030-01-01T00:00:00&per_page=1 |
admin | 200 | 200 1 items: 1 total=269 | ✅ |
| before invalid | GET /sites?before=yesterday |
admin | 400 | 400 rest_invalid_param (rest_invalid_date) | ✅ |
| after ISO | GET /sites?after=2026-11-06T00:00:00 |
admin | 200 | 200 8 items: 354,355,356,357,358,359,360,361 total=8 | ✅ |
| after invalid | GET /sites?after=2026-13-45 |
admin | 400 | 400 rest_invalid_param (rest_invalid_date) | ✅ |
| unknown param ignored | GET /sites?foo=bar&per_page=1 |
admin | 200 | 200 1 items: 1 total=269 | ✅ |
GET /sites/{id} (12 cases, 12 ✅)
| Test case | Request | Auth | Expected | Actual | Result |
|---|---|---|---|---|---|
| view | GET /sites/354 |
admin | 200 | 200 id=354 localhost:8888/r1106-s1/ | ✅ |
| embed | GET /sites/354?context=embed |
admin | 200 | 200 id=354 localhost:8888/r1106-s1/ | ✅ |
| edit | GET /sites/354?context=edit |
admin | 200 | 200 id=354 localhost:8888/r1106-s1/ | ✅ |
| context invalid | GET /sites/354?context=foo |
admin | 400 | 400 rest_invalid_param (rest_not_in_enum) | ✅ |
| main site | GET /sites/1 |
admin | 200 | 200 id=1 localhost:8888/ | ✅ |
| nonexistent | GET /sites/999999 |
admin | 404 | 404 rest_site_invalid_id | ✅ |
| zero | GET /sites/0 |
admin | 404 | 404 rest_site_invalid_id | ✅ |
| negative (no route) | GET /sites/-1 |
admin | 404 | 404 rest_no_route | ✅ |
| float (no route) | GET /sites/1.5 |
admin | 404 | 404 rest_no_route | ✅ |
| non-numeric (no route) | GET /sites/abc |
admin | 404 | 404 rest_no_route | ✅ |
| HEAD | HEAD /sites/354 |
admin | 200 | 200 (no body) | ✅ |
| leading zeros | GET /sites/0354 |
admin | 200 | 200 id=354 localhost:8888/r1106-s1/ | ✅ |
POST /sites (103 cases, 91 ✅)
| Test case | Request | Auth | Expected | Actual | Result |
|---|---|---|---|---|---|
| minimal valid | POST /sites {"domain":"localhost:8888","path":"/r1106-c1/"} |
admin | 201 | 201 id=362 localhost:8888/r1106-c1/ | ✅ |
| duplicate domain+path | POST /sites {"domain":"localhost:8888","path":"/r1106-c1/"} |
admin | 400 | 400 rest_site_taken | ✅ |
| duplicate, other case | POST /sites {"domain":"localhost:8888","path":"/R1106-C1/"} |
admin | 400 | 400 rest_site_taken | ✅ |
| path missing | POST /sites {"domain":"localhost:8888"} |
admin | 400 | 400 rest_missing_callback_param | ✅ |
| path empty | POST /sites {"domain":"localhost:8888","path":""} |
admin | 400 | 400 rest_invalid_param (rest_invalid_param) | ✅ |
| path / | POST /sites {"domain":"localhost:8888","path":"/"} |
admin | 400 | 400 rest_site_taken | ✅ |
| path int | POST /sites {"domain":"localhost:8888","path":5} |
admin | 400 | 400 rest_invalid_param (rest_invalid_type) | ✅ |
| path array | POST /sites {"domain":"localhost:8888","path":["/r1106-x/"]} |
admin | 400 | 400 rest_invalid_param (rest_invalid_type) | ✅ |
| path null | POST /sites {"domain":"localhost:8888","path":null} |
admin | 400 | 400 rest_missing_callback_param | ✅ |
| path no trailing slash | POST /sites {"domain":"localhost:8888","path":"/r1106-nt"} |
admin | 400 | 400 rest_invalid_param (rest_invalid_param) | ✅ |
| path no leading slash | POST /sites {"domain":"localhost:8888","path":"r1106-nl/"} |
admin | 400 | 400 rest_invalid_param (rest_invalid_param) | ✅ |
| path // | POST /sites {"domain":"localhost:8888","path":"//"} |
admin | 400 | 400 rest_invalid_param (rest_invalid_param) | ✅ |
| path double slash | POST /sites {"domain":"localhost:8888","path":"/r1106-x//"} |
admin | 400 | 400 rest_invalid_param (rest_invalid_param) | ✅ |
| path nested | POST /sites {"domain":"localhost:8888","path":"/r1106-a/r1106-b/"} |
admin | 400 | 400 rest_invalid_param (rest_invalid_param) | ✅ |
| path dot | POST /sites {"domain":"localhost:8888","path":"/r1106.x/"} |
admin | 400 | 400 rest_invalid_param (rest_invalid_param) | ✅ |
| path underscore | POST /sites {"domain":"localhost:8888","path":"/r1106_x/"} |
admin | 400 | 400 rest_invalid_param (rest_invalid_param) | ✅ |
| path quote | POST /sites {"domain":"localhost:8888","path":"/r1106'x/"} |
admin | 400 | 400 rest_invalid_param (rest_invalid_param) | ✅ |
| path .. | POST /sites {"domain":"localhost:8888","path":"/r1106/../"} |
admin | 400 | 400 rest_invalid_param (rest_invalid_param) | ✅ |
| path %2e%2e | POST /sites {"domain":"localhost:8888","path":"/%2e%2e/"} |
admin | 400 | 400 rest_invalid_param (rest_invalid_param) | ✅ |
| path %2E | POST /sites {"domain":"localhost:8888","path":"/%2E/"} |
admin | 400 | 400 rest_invalid_param (rest_invalid_param) | ✅ |
| path utf8 encoded | POST /sites {"domain":"localhost:8888","path":"/r1106-caf%C3%A9/"} |
admin | 400 | 400 rest_invalid_param (rest_invalid_param) | ✅ |
| path utf8 raw | POST /sites {"domain":"localhost:8888","path":"/r1106-café/"} |
admin | 400 | 400 rest_invalid_param (rest_invalid_param) | ✅ |
| path %2F | POST /sites {"domain":"localhost:8888","path":"/r1106-a%2Fb/"} |
admin | 400 | 400 rest_invalid_param (rest_invalid_param) | ✅ |
| path space | POST /sites {"domain":"localhost:8888","path":"/r1106-sp /"} |
admin | 400 | 400 rest_invalid_param (rest_invalid_param) | ✅ |
| path robots.txt | POST /sites {"domain":"localhost:8888","path":"/robots.txt/"} |
admin | 400 | 400 rest_invalid_param (rest_invalid_param) | ✅ |
| path wp-sitemap.xml | POST /sites {"domain":"localhost:8888","path":"/wp-sitemap.xml/"} |
admin | 400 | 400 rest_invalid_param (rest_invalid_param) | ✅ |
| path favicon.ico | POST /sites {"domain":"localhost:8888","path":"/favicon.ico/"} |
admin | 400 | 400 rest_invalid_param (rest_invalid_param) | ✅ |
| path .well-known | POST /sites {"domain":"localhost:8888","path":"/.well-known/"} |
admin | 400 | 400 rest_invalid_param (rest_invalid_param) | ✅ |
| path wp-login.php | POST /sites {"domain":"localhost:8888","path":"/wp-login.php/"} |
admin | 400 | 400 rest_invalid_param (rest_invalid_param) | ✅ |
| path wp-login%2ephp | POST /sites {"domain":"localhost:8888","path":"/wp-login%2ephp/"} |
admin | 400 | 400 rest_invalid_param (rest_invalid_param) | ✅ |
| path reserved wp-json | POST /sites {"domain":"localhost:8888","path":"/wp-json/"} |
admin | 400 | 400 rest_invalid_param (rest_invalid_param) | ✅ |
| path reserved WP-JSON | POST /sites {"domain":"localhost:8888","path":"/WP-JSON/"} |
admin | 400 | 400 rest_invalid_param (rest_invalid_param) | ✅ |
| path reserved wp-admin | POST /sites {"domain":"localhost:8888","path":"/wp-admin/"} |
admin | 400 | 400 rest_invalid_param (rest_invalid_param) | ✅ |
| path reserved wp-content | POST /sites {"domain":"localhost:8888","path":"/wp-content/"} |
admin | 400 | 400 rest_invalid_param (rest_invalid_param) | ✅ |
| path reserved wp-includes | POST /sites {"domain":"localhost:8888","path":"/wp-includes/"} |
admin | 400 | 400 rest_invalid_param (rest_invalid_param) | ✅ |
| path reserved files | POST /sites {"domain":"localhost:8888","path":"/files/"} |
admin | 400 | 400 rest_invalid_param (rest_invalid_param) | ✅ |
| path reserved blog | POST /sites {"domain":"localhost:8888","path":"/blog/"} |
admin | 400 | 400 rest_invalid_param (rest_invalid_param) | ✅ |
| path reserved page | POST /sites {"domain":"localhost:8888","path":"/page/"} |
admin | 400 | 400 rest_invalid_param (rest_invalid_param) | ✅ |
| path reserved feed | POST /sites {"domain":"localhost:8888","path":"/feed/"} |
admin | 400 | 400 rest_invalid_param (rest_invalid_param) | ✅ |
| path reserved embed | POST /sites {"domain":"localhost:8888","path":"/embed/"} |
admin | 400 | 400 rest_invalid_param (rest_invalid_param) | ✅ |
| path reserved comments | POST /sites {"domain":"localhost:8888","path":"/comments/"} |
admin | 400 | 400 rest_invalid_param (rest_invalid_param) | ✅ |
| path only hyphen | POST /sites {"domain":"localhost:8888","path":"/-/"} |
admin | 400 | 201 id=363 localhost:8888/-/ | ℹ️ I5 |
| path only digits | POST /sites {"domain":"localhost:8888","path":"/r1106123/"} |
admin | 201 | 201 id=364 localhost:8888/r1106123/ | ✅ |
| path trailing newline | POST /sites {"domain":"localhost:8888","path":"/r1106-nl1/\n"} |
admin | 400 | 201 id=365 localhost:8888/r1106-nl1/\n/ | |
| path leading newline | POST /sites {"domain":"localhost:8888","path":"\n/r1106-nl2/"} |
admin | 400 | 400 rest_invalid_param (rest_invalid_param) | ✅ |
| path NUL | POST /sites {"domain":"localhost:8888","path":"/r1106-nul\u0000/"} |
admin | 400 | 400 rest_invalid_param (rest_invalid_param) | ✅ |
| path tab | POST /sites {"domain":"localhost:8888","path":"/r1106-tab\t/"} |
admin | 400 | 400 rest_invalid_param (rest_invalid_param) | ✅ |
| path very long | POST /sites {"domain":"localhost:8888","path":"/r1106-aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa… |
admin | 400 | 400 rest_invalid_param (rest_too_long) | ✅ |
| path uppercase lowercased | POST /sites {"domain":"localhost:8888","path":"/R1106-Upper/"} |
admin | 201 | 201 id=366 localhost:8888/r1106-upper/ | ✅ |
| path / on other domain | POST /sites {"domain":"r1106.example.test","path":"/"} |
admin | 201 | 201 id=367 r1106.example.test/ | ✅ |
| domain missing | POST /sites {"path":"/r1106-nodom/"} |
admin | 201 | 400 rest_invalid_param (rest_invalid_param) | |
| domain empty | POST /sites {"domain":"","path":"/r1106-emptydom/"} |
admin | 201 | 400 rest_invalid_param (rest_invalid_param) | |
| domain int | POST /sites {"domain":5,"path":"/r1106-x1/"} |
admin | 400 | 400 rest_invalid_param (rest_invalid_type) | ✅ |
| domain array | POST /sites {"domain":["a"],"path":"/r1106-x2/"} |
admin | 400 | 400 rest_invalid_param (rest_invalid_type) | ✅ |
| domain with scheme | POST /sites {"domain":"http://r1106.test","path":"/r1106-x3/"} |
admin | 400 | 400 rest_invalid_param (rest_invalid_param) | ✅ |
| domain with path | POST /sites {"domain":"r1106.test/x","path":"/r1106-x4/"} |
admin | 400 | 400 rest_invalid_param (rest_invalid_param) | ✅ |
| domain with space | POST /sites {"domain":"r1106 .test","path":"/r1106-x5/"} |
admin | 400 | 400 rest_invalid_param (rest_invalid_param) | ✅ |
| domain port 0 | POST /sites {"domain":"r1106.test:0","path":"/r1106-x6/"} |
admin | 400 | 400 rest_invalid_param (rest_invalid_param) | ✅ |
| domain port 70000 | POST /sites {"domain":"r1106.test:70000","path":"/r1106-x7/"} |
admin | 400 | 400 rest_invalid_param (rest_invalid_param) | ✅ |
| domain 254 chars | POST /sites {"domain":"aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa… |
admin | 400 | 400 rest_invalid_param (rest_too_long) | ✅ |
| domain uppercase | POST /sites {"domain":"R1106-Up.Example.Test","path":"/r1106-x9/"} |
admin | 400 | 201 id=368 R1106-Up.Example.Test/r1106-x9/ | ℹ️ L1 |
| domain leading zero port | POST /sites {"domain":"localhost:08888","path":"/r1106-x10/"} |
admin | 400 | 201 id=369 localhost:08888/r1106-x10/ | ℹ️ L1 |
| domain ::1 | POST /sites {"domain":"::1","path":"/r1106-x11/"} |
admin | 400 | 201 id=370 ::1/r1106-x11/ | ℹ️ L1 |
| domain 999.999.999.999 | POST /sites {"domain":"999.999.999.999","path":"/r1106-x12/"} |
admin | 400 | 201 id=371 999.999.999.999/r1106-x12/ | ℹ️ L1 |
| domain 123 | POST /sites {"domain":"123","path":"/r1106-x13/"} |
admin | 400 | 201 id=372 123/r1106-x13/ | ℹ️ L1 |
| domain trailing dot | POST /sites {"domain":"r1106.example.test.","path":"/r1106-x14/"} |
admin | 400 | 400 rest_invalid_param (rest_invalid_param) | ✅ |
| domain leading hyphen | POST /sites {"domain":"-r1106.test","path":"/r1106-x15/"} |
admin | 400 | 400 rest_invalid_param (rest_invalid_param) | ✅ |
| domain underscore | POST /sites {"domain":"r1106_x.test","path":"/r1106-x16/"} |
admin | 400 | 400 rest_invalid_param (rest_invalid_param) | ✅ |
| domain newline | POST /sites {"domain":"r1106.test\n","path":"/r1106-x17/"} |
admin | 201 | 201 id=373 r1106.test/r1106-x17/ | ✅ (stored without the newline) |
| public false | POST /sites {"domain":"localhost:8888","path":"/r1106-pf/","public":false} |
admin | 201 | 201 id=374 localhost:8888/r1106-pf/ | ✅ |
| public string | POST /sites {"domain":"localhost:8888","path":"/r1106-x18/","public":"maybe"} |
admin | 400 | 400 rest_invalid_param (rest_invalid_type) | ✅ |
| archived true | POST /sites {"domain":"localhost:8888","path":"/r1106-arch/","archived":true} |
admin | 201 | 201 id=375 localhost:8888/r1106-arch/ | ✅ |
| archived int 2 | POST /sites {"domain":"localhost:8888","path":"/r1106-x19/","archived":2} |
admin | 400 | 400 rest_invalid_param (rest_invalid_type) | ✅ |
| mature true | POST /sites {"domain":"localhost:8888","path":"/r1106-mat/","mature":true} |
admin | 201 | 201 id=376 localhost:8888/r1106-mat/ | ✅ |
| spam true | POST /sites {"domain":"localhost:8888","path":"/r1106-spam/","spam":true} |
admin | 201 | 201 id=377 localhost:8888/r1106-spam/ | ✅ |
| deleted true | POST /sites {"domain":"localhost:8888","path":"/r1106-del/","deleted":true} |
admin | 201 | 201 id=378 localhost:8888/r1106-del/ | ✅ |
| deleted string | POST /sites {"domain":"localhost:8888","path":"/r1106-x20/","deleted":"x"} |
admin | 400 | 400 rest_invalid_param (rest_invalid_type) | ✅ |
| lang_id 1 | POST /sites {"domain":"localhost:8888","path":"/r1106-lang/","lang_id":1} |
admin | 201 | 201 id=379 localhost:8888/r1106-lang/ | ✅ |
| lang_id string | POST /sites {"domain":"localhost:8888","path":"/r1106-x21/","lang_id":"abc"} |
admin | 400 | 400 rest_invalid_param (rest_invalid_type) | ✅ |
| lang_id float | POST /sites {"domain":"localhost:8888","path":"/r1106-x22/","lang_id":1.5} |
admin | 400 | 400 rest_invalid_param (rest_invalid_type) | ✅ |
| lang_id -5 | POST /sites {"domain":"localhost:8888","path":"/r1106-lneg/","lang_id":-5} |
admin | 400 | 201 id=380 localhost:8888/r1106-lneg/ | ℹ️ L2 |
| lang_id 2147483648 | POST /sites {"domain":"localhost:8888","path":"/r1106-lbig/","lang_id":2147483648} |
admin | 400 | 201 id=381 localhost:8888/r1106-lbig/ | ℹ️ L2 (stored as 2147483647) |
| blogname | POST /sites {"domain":"localhost:8888","path":"/r1106-name/","blogname":"R9 <b>Name</b>"} |
admin | 201 | 201 id=382 localhost:8888/r1106-name/ | ✅ |
| blogname script | POST /sites {"domain":"localhost:8888","path":"/r1106-xss/","blogname":"<script>alert(1)</script>"} |
admin | 201 | 201 id=383 localhost:8888/r1106-xss/ | ✅ |
| blogname empty | POST /sites {"domain":"localhost:8888","path":"/r1106-noname/","blogname":""} |
admin | 201 | 201 id=384 localhost:8888/r1106-noname/ | ✅ |
| blogname array | POST /sites {"domain":"localhost:8888","path":"/r1106-x23/","blogname":["a"]} |
admin | 400 | 400 rest_invalid_param (rest_invalid_type) | ✅ |
| user 3 | POST /sites {"domain":"localhost:8888","path":"/r1106-u3/","user":3} |
admin | 201 | 201 id=385 localhost:8888/r1106-u3/ | ✅ |
| user me | POST /sites {"domain":"localhost:8888","path":"/r1106-ume/","user":"me"} |
admin | 201 | 201 id=386 localhost:8888/r1106-ume/ | ✅ |
| user nonexistent | POST /sites {"domain":"localhost:8888","path":"/r1106-x24/","user":999999} |
admin | 400 | 400 rest_user_invalid_id | ✅ |
| user 0 | POST /sites {"domain":"localhost:8888","path":"/r1106-x25/","user":0} |
admin | 400 | 400 rest_invalid_param (rest_no_matching_schema) | ✅ |
| user login string | POST /sites {"domain":"localhost:8888","path":"/r1106-x26/","user":"bbsub"} |
admin | 400 | 400 rest_invalid_param (rest_no_matching_schema) | ✅ |
| id given (existing) | POST /sites {"domain":"localhost:8888","path":"/r1106-x27/","id":5} |
admin | 400 | 400 rest_site_exists | ✅ |
| meta all types | POST /sites {"domain":"localhost:8888","path":"/r1106-meta/","meta":{"rest_test_string":"s","rest_test_boolean":true,"rest_test_integer":… |
admin | 201 | 201 id=387 localhost:8888/r1106-meta/ | ✅ |
| meta string wrong type | POST /sites {"domain":"localhost:8888","path":"/r1106-mx1/","meta":{"rest_test_string":["a"]}} |
admin | 400 | 400 rest_invalid_type | ✅ |
| meta boolean wrong type | POST /sites {"domain":"localhost:8888","path":"/r1106-mx2/","meta":{"rest_test_boolean":"maybe"}} |
admin | 400 | 400 rest_invalid_type | ✅ |
| meta integer wrong type | POST /sites {"domain":"localhost:8888","path":"/r1106-mx3/","meta":{"rest_test_integer":"abc"}} |
admin | 400 | 400 rest_invalid_type | ✅ |
| meta array wrong type | POST /sites {"domain":"localhost:8888","path":"/r1106-mx4/","meta":{"rest_test_array":"abc"}} |
admin | 400 | 201 id=388 localhost:8888/r1106-mx4/ | ℹ️ I6 |
| meta multi wrong item | POST /sites {"domain":"localhost:8888","path":"/r1106-mx5/","meta":{"rest_test_multi":[["x"]]}} |
admin | 400 | 400 rest_invalid_type | ✅ |
| meta hidden key | POST /sites {"domain":"localhost:8888","path":"/r1106-mhid/","meta":{"rest_test_hidden":"x"}} |
admin | 201 | 201 id=389 localhost:8888/r1106-mhid/ | ✅ |
| meta unregistered key | POST /sites {"domain":"localhost:8888","path":"/r1106-munreg/","meta":{"unreg_key":"x"}} |
admin | 201 | 201 id=390 localhost:8888/r1106-munreg/ | ✅ |
| meta not object | POST /sites {"domain":"localhost:8888","path":"/r1106-mx6/","meta":"x"} |
admin | 400 | 400 rest_invalid_param | ✅ |
| meta null value | POST /sites {"domain":"localhost:8888","path":"/r1106-mnull/","meta":{"rest_test_string":null}} |
admin | 201 | 201 id=391 localhost:8888/r1106-mnull/ | ✅ |
| malformed JSON | POST /sites {"path": |
admin | 400 | 400 rest_invalid_json | ✅ |
PUT/PATCH /sites/{id} (47 cases, 45 ✅)
| Test case | Request | Auth | Expected | Actual | Result |
|---|---|---|---|---|---|
| public false | PUT /sites/355 {"public":false} |
admin | 200 | 200 id=355 localhost:8888/r1106-s2/ | ✅ |
| public true | PUT /sites/355 {"public":true} |
admin | 200 | 200 id=355 localhost:8888/r1106-s2/ | ✅ |
| public string | PUT /sites/355 {"public":"maybe"} |
admin | 400 | 400 rest_invalid_param (rest_invalid_type) | ✅ |
| archived true | PUT /sites/355 {"archived":true} |
admin | 200 | 200 id=355 localhost:8888/r1106-s2/ | ✅ |
| archived false | PUT /sites/355 {"archived":false} |
admin | 200 | 200 id=355 localhost:8888/r1106-s2/ | ✅ |
| archived int 2 | PUT /sites/355 {"archived":2} |
admin | 400 | 400 rest_invalid_param (rest_invalid_type) | ✅ |
| mature true | PUT /sites/355 {"mature":true} |
admin | 200 | 200 id=355 localhost:8888/r1106-s2/ | ✅ |
| mature false | PUT /sites/355 {"mature":false} |
admin | 200 | 200 id=355 localhost:8888/r1106-s2/ | ✅ |
| spam true | PUT /sites/355 {"spam":true} |
admin | 200 | 200 id=355 localhost:8888/r1106-s2/ | ✅ |
| spam false | PUT /sites/355 {"spam":false} |
admin | 200 | 200 id=355 localhost:8888/r1106-s2/ | ✅ |
| deleted true | PUT /sites/355 {"deleted":true} |
admin | 200 | 200 id=355 localhost:8888/r1106-s2/ | ✅ |
| deleted false | PUT /sites/355 {"deleted":false} |
admin | 200 | 200 id=355 localhost:8888/r1106-s2/ | ✅ |
| deleted string | PUT /sites/355 {"deleted":"x"} |
admin | 400 | 400 rest_invalid_param (rest_invalid_type) | ✅ |
| lang_id 1 | PUT /sites/355 {"lang_id":1} |
admin | 200 | 200 id=355 localhost:8888/r1106-s2/ | ✅ |
| lang_id 0 | PUT /sites/355 {"lang_id":0} |
admin | 200 | 200 id=355 localhost:8888/r1106-s2/ | ✅ |
| lang_id string | PUT /sites/355 {"lang_id":"abc"} |
admin | 400 | 400 rest_invalid_param (rest_invalid_type) | ✅ |
| lang_id -1 | PUT /sites/355 {"lang_id":-1} |
admin | 400 | 200 id=355 localhost:8888/r1106-s2/ | ℹ️ L2 |
| PATCH public | PATCH /sites/355 {"public":false} |
admin | 200 | 200 id=355 localhost:8888/r1106-s2/ | ✅ |
| POST update public | POST /sites/355 {"public":true} |
admin | 200 | 200 id=355 localhost:8888/r1106-s2/ | ✅ |
| empty body | PUT /sites/355 |
admin | 200 | 200 id=355 localhost:8888/r1106-s2/ | ✅ |
| nonexistent site | PUT /sites/999999 {"public":false} |
admin | 404 | 404 rest_site_invalid_id | ✅ |
| site 0 | PUT /sites/0 {"public":false} |
admin | 404 | 404 rest_site_invalid_id | ✅ |
| blogname ignored | PUT /sites/355 {"blogname":"Changed"} |
admin | 200 | 200 id=355 localhost:8888/r1106-s2/ | ✅ |
| user ignored | PUT /sites/355 {"user":1} |
admin | 200 | 200 id=355 localhost:8888/r1106-s2/ | ✅ |
| readonly siteurl ignored | PUT /sites/355 {"siteurl":"http://evil.test/"} |
admin | 200 | 200 id=355 localhost:8888/r1106-s2/ | ✅ |
| readonly network ignored | PUT /sites/355 {"network":2} |
admin | 200 | 200 id=355 localhost:8888/r1106-s2/ | ✅ |
| path to taken path | PUT /sites/355 {"path":"/r1106-s1/"} |
admin | 400 | 400 rest_site_taken | ✅ |
| path taken, other case | PUT /sites/355 {"path":"/R1106-S1/"} |
admin | 400 | 400 rest_site_taken | ✅ |
| path same value | PUT /sites/355 {"path":"/r1106-s2/"} |
admin | 200 | 200 id=355 localhost:8888/r1106-s2/ | ✅ |
| path invalid nested | PUT /sites/355 {"path":"/r1106-a/r1106-b/"} |
admin | 400 | 400 rest_invalid_param (rest_invalid_param) | ✅ |
| path robots.txt | PUT /sites/355 {"path":"/robots.txt/"} |
admin | 400 | 400 rest_invalid_param (rest_invalid_param) | ✅ |
| path %2e%2e | PUT /sites/355 {"path":"/%2e%2e/"} |
admin | 400 | 400 rest_invalid_param (rest_invalid_param) | ✅ |
| path dot | PUT /sites/355 {"path":"/r1106.x/"} |
admin | 400 | 400 rest_invalid_param (rest_invalid_param) | ✅ |
| path wp-json | PUT /sites/355 {"path":"/wp-json/"} |
admin | 400 | 400 rest_invalid_param (rest_invalid_param) | ✅ |
| path trailing newline | PUT /sites/355 {"path":"/r1106-s2/\n"} |
admin | 400 | 200 id=355 localhost:8888/r1106-s2/\n/ | |
| path / | PUT /sites/355 {"path":"/"} |
admin | 400 | 400 rest_site_taken | ✅ |
| domain invalid | PUT /sites/355 {"domain":"http://x.test"} |
admin | 400 | 400 rest_invalid_param (rest_invalid_param) | ✅ |
| domain int | PUT /sites/355 {"domain":5} |
admin | 400 | 400 rest_invalid_param (rest_invalid_type) | ✅ |
| meta string | PUT /sites/355 {"meta":{"rest_test_string":"upd"}} |
admin | 200 | 200 id=355 localhost:8888/r1106-s2/\n/ | ✅ |
| meta integer | PUT /sites/355 {"meta":{"rest_test_integer":3}} |
admin | 200 | 200 id=355 localhost:8888/r1106-s2/\n/ | ✅ |
| meta multi | PUT /sites/355 {"meta":{"rest_test_multi":["x"]}} |
admin | 200 | 200 id=355 localhost:8888/r1106-s2/\n/ | ✅ |
| meta wrong type + flag | PUT /sites/355 {"public":false,"meta":{"rest_test_integer":"abc"}} |
admin | 400 | 400 rest_invalid_type | ✅ |
| meta wrong type + path | PUT /sites/355 {"path":"/r1106-s2-mv/","meta":{"rest_test_boolean":"maybe"}} |
admin | 400 | 400 rest_invalid_type | ✅ |
| meta hidden key | PUT /sites/355 {"meta":{"rest_test_hidden":"x"}} |
admin | 200 | 200 id=355 localhost:8888/r1106-s2/\n/ | ✅ |
| meta unregistered key | PUT /sites/355 {"meta":{"unreg_key":"x"}} |
admin | 200 | 200 id=355 localhost:8888/r1106-s2/\n/ | ✅ |
| meta null deletes | PUT /sites/355 {"meta":{"rest_test_string":null}} |
admin | 200 | 200 id=355 localhost:8888/r1106-s2/\n/ | ✅ |
| meta not object | PUT /sites/355 {"meta":"x"} |
admin | 400 | 400 rest_invalid_param | ✅ |
id must match the URL (run 8 M1) (25 cases, 23 ✅)
| Test case | Request | Auth | Expected | Actual | Result |
|---|---|---|---|---|---|
| PUT body id mismatch | PUT /sites/355 {"id":354,"public":false} |
admin | 400 | 400 rest_invalid_param (rest_site_id_mismatch) | ✅ |
| PUT query id mismatch | PUT /sites/355?id=354 {"public":false} |
admin | 400 | 400 rest_invalid_param (rest_site_id_mismatch) | ✅ |
| POST body id mismatch | POST /sites/355 {"id":354,"lang_id":0} |
admin | 400 | 400 rest_invalid_param (rest_site_id_mismatch) | ✅ |
| PATCH body id mismatch | PATCH /sites/355 {"id":354,"lang_id":0} |
admin | 400 | 400 rest_invalid_param (rest_site_id_mismatch) | ✅ |
| GET query id mismatch | GET /sites/354?id=355 |
admin | 400 | 400 rest_invalid_param (rest_site_id_mismatch) | ✅ |
| HEAD query id mismatch | HEAD /sites/354?id=355 |
admin | 400 | 400 (no body) | ✅ |
| DELETE id mismatch, force | DELETE /sites/358?id=359&force=true |
admin | 400 | 400 rest_invalid_param (rest_site_id_mismatch) | ✅ |
| DELETE body id mismatch, force | DELETE /sites/358?force=true {"id":359} |
admin | 400 | 400 rest_invalid_param (rest_site_id_mismatch) | ✅ |
| PUT body id matching | PUT /sites/355 {"id":355,"lang_id":0} |
admin | 200 | 200 id=355 localhost:8888/r1106-s2/\n/ | ✅ |
| PUT body id as string | PUT /sites/355 {"id":"355","lang_id":0} |
admin | 200 | 200 id=355 localhost:8888/r1106-s2/\n/ | ✅ |
| PUT body id string mismatch | PUT /sites/355 {"id":"354","lang_id":0} |
admin | 400 | 400 rest_invalid_param (rest_site_id_mismatch) | ✅ |
| PUT body id float equal | PUT /sites/355 {"id":355.0,"lang_id":0} |
admin | 200 | 200 id=355 localhost:8888/r1106-s2/\n/ | ✅ |
| PUT body id float 355.9 | PUT /sites/355 {"id":355.9,"lang_id":0} |
admin | 400 | 400 rest_invalid_param (rest_invalid_type) | ✅ |
| PUT body id "355abc" | PUT /sites/355 {"id":"355abc","lang_id":0} |
admin | 400 | 400 rest_invalid_param (rest_invalid_type) | ✅ |
| PUT body id array | PUT /sites/355 {"id":[354],"lang_id":0} |
admin | 400 | 400 rest_invalid_param (rest_invalid_type) | ✅ |
| PUT body id null | PUT /sites/355 {"id":null,"lang_id":0} |
admin | 400 | 400 rest_invalid_param (rest_invalid_type) | ✅ (400 rest_invalid_type is fine) |
| PUT body id true | PUT /sites/355 {"id":true,"lang_id":0} |
admin | 400 | 400 rest_invalid_param (rest_invalid_type) | ✅ |
| PUT body id 0 | PUT /sites/355 {"id":0,"lang_id":0} |
admin | 400 | 400 rest_invalid_param (rest_site_id_mismatch) | ✅ |
| PUT body id -355 | PUT /sites/355 {"id":-355,"lang_id":0} |
admin | 400 | 400 rest_invalid_param (rest_site_id_mismatch) | ✅ |
| GET query id matching | GET /sites/354?id=354 |
admin | 200 | 200 id=354 localhost:8888/r1106-s1/ | ✅ |
| GET URL leading zeros + query id | GET /sites/0354?id=354 |
admin | 200 | 200 id=354 localhost:8888/r1106-s1/ | ✅ |
| main site via body id=1 | PUT /sites/354 {"id":1,"archived":true} |
admin | 400 | 400 rest_invalid_param (rest_site_id_mismatch) | ✅ |
| anon id mismatch | PUT /sites/355 {"id":354,"public":false} |
anon | 401 | 400 rest_invalid_param (rest_site_id_mismatch) | ℹ️ I2 |
| member id mismatch | PUT /sites/355 {"id":354,"public":false} |
bb | 403 | 400 rest_invalid_param (rest_site_id_mismatch) | ℹ️ I2 |
| POST collection id ignored-ish | POST /sites {"domain":"localhost:8888","path":"/r1106-cid/","id":999999} |
admin | 400 | 400 rest_site_exists | ✅ |
DELETE /sites/{id} (15 cases, 15 ✅)
| Test case | Request | Auth | Expected | Actual | Result |
|---|---|---|---|---|---|
| force invalid string | DELETE /sites/357?force=maybe |
admin | 400 | 400 rest_invalid_param (rest_invalid_type) | ✅ |
| force int 2 | DELETE /sites/357?force=2 |
admin | 400 | 400 rest_invalid_param (rest_invalid_type) | ✅ |
| force array | DELETE /sites/357?force[]=1 |
admin | 400 | 400 rest_invalid_param (rest_invalid_type) | ✅ |
| nonexistent | DELETE /sites/999999 |
admin | 404 | 404 rest_site_invalid_id | ✅ |
| nonexistent force | DELETE /sites/999999?force=true |
admin | 404 | 404 rest_site_invalid_id | ✅ |
| site 0 | DELETE /sites/0?force=true |
admin | 404 | 404 rest_site_invalid_id | ✅ |
| non-numeric (no route) | DELETE /sites/abc |
admin | 404 | 404 rest_no_route | ✅ |
| collection DELETE | DELETE /sites |
admin | 404 | 404 rest_no_route | ✅ |
| force=false explicit (soft) | DELETE /sites/359?force=false |
admin | 200 | 200 deleted=True | ✅ |
| _method=DELETE override (soft) | POST /sites/359?_method=DELETE |
admin | 200 | 200 deleted=True | ✅ |
| force=true | DELETE /sites/357?force=true |
admin | 200 | 200 deleted=True | ✅ |
| GET after force | GET /sites/357 |
admin | 404 | 404 rest_site_invalid_id | ✅ |
| force again | DELETE /sites/357?force=true |
admin | 404 | 404 rest_site_invalid_id | ✅ |
| force=1 (body) | DELETE /sites/358 {"force":true} |
admin | 200 | 200 deleted=True | ✅ |
| PUT after force | PUT /sites/358 {"public":false} |
admin | 404 | 404 rest_site_invalid_id | ✅ |
Scope notes
- Subdomain installs and networks with a base path other than
/weren't tested (get_network()->pathinis_valid_path()). - No multi-network setup, so
network_idacross networks wasn't tested. - Leftover sites from earlier runs stay in the env (run 9: 354–392 except force-deleted 357, 358 and 365). Teardown removed the mu-plugin and all application passwords for admin and bbsub; no
wp-env clean. - The
httpsmove case: the API response showssiteurlwithhttp://because core applies the request scheme on output; the stored option keepshttps://.
This closes some open issues in the REST API endpoints for Sites.