Skip to content

REST API: Rename check_domain_is_available() to check_url_is_available() - #6

Merged
lloc merged 2 commits into
lloc:feature/40365-rest-sites-endpointfrom
spacedmonkey:fix/40365-check-url-is-available
Sep 30, 2026
Merged

lloc merged 2 commits into
lloc:feature/40365-rest-sites-endpointfrom
spacedmonkey:fix/40365-check-url-is-available

Conversation

@spacedmonkey

Copy link
Copy Markdown

Summary

Actions @peterwilsoncc's review feedback: WordPress#13055 (comment)

check_domain_is_available() checks both the domain and path of a prepared site (see domain_exists( $domain, $path, $network_id ) inside it), not just the domain, so the name was misleading. Renamed to check_url_is_available(), since domain + path together form the site's URL.

  • Renamed the method and updated its one call site in prepare_item_for_database() (also renamed the local $domain_check variable to $url_check for consistency).
  • The docblock already described the domain+path behavior accurately, so no doc changes were needed there.
  • No test references the method by name (it's only exercised indirectly through create_item/update_item), so no test changes were needed either — confirmed the existing domain/path-conflict tests (test_create_item_domain_validation, the update_item equivalent, etc.) still pass unchanged, since this is a pure rename with no behavior change.

Test plan

  • WP_Test_REST_Sites_Controller passes against a single-site install
  • WP_Test_REST_Sites_Controller passes against a multisite install
  • composer lint (phpcs) clean on the changed file

🤖 Generated with Claude Code

…e().

The method checks both the `domain` and `path` of a prepared site, not
just the domain, so `check_domain_is_available()` was a misleading name.
Renamed to check_url_is_available() (domain + path together form the
site's URL) and updated its one call site accordingly. Docblock already
described the domain+path behavior correctly and needed no changes; no
tests reference the method by name, and the existing domain/path-taken
conflict tests (test_create_item_domain_validation, test_update_item_*)
continue to pass unchanged since this is a pure rename with no behavior
change.

See #40365.

Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
@github-actions

Copy link
Copy Markdown

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 props-bot label.

Core Committers: Use this line as a base for the props when committing in SVN:

Props spacedmonkey.

To understand the WordPress project's expectations around crediting contributors, please review the Contributor Attribution page in the Core Handbook.

Adds a get_reflective_method() helper (matching the pattern already used
in wpRestUrlDetailsController.php) to directly unit test the renamed
protected method, rather than only exercising it indirectly through
create_item()/update_item().

Covers, using @dataProvider where the setup is shared:
- create: a brand new domain/path is available, an existing one is
  rejected, and omitting `path` entirely falls back to '/' and still
  conflicts (test_check_url_is_available_on_create, 3 data sets).
- update: keeping the site's own domain/path via the current-site
  fallback is not a conflict, changing to another site's domain/path is
  (test_check_url_is_available_on_update, 2 data sets).
- the same domain/path is available on a different network (standalone,
  needs its own network fixture).
- an invalid site ID on update propagates get_site()'s WP_Error rather
  than reaching the domain/path check (standalone, distinct assertion).

Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
@lloc
lloc merged commit 7c9f2e3 into lloc:feature/40365-rest-sites-endpoint Sep 30, 2026
3 checks passed
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