Skip to content

fix: auto-promote custom domain to primary on DNS verification for 3-part domains#991

Merged
superdav42 merged 1 commit into
mainfrom
fix/domain-auto-promote-is-main-domain
Apr 29, 2026
Merged

fix: auto-promote custom domain to primary on DNS verification for 3-part domains#991
superdav42 merged 1 commit into
mainfrom
fix/domain-auto-promote-is-main-domain

Conversation

@superdav42

Copy link
Copy Markdown
Collaborator

Summary

  • Root cause: maybe_auto_promote_primary_domain (added in fix: site provisioning hardening — limitations, membership inference, domain promotion #965) had two bugs: (1) is_main_domain() TLD-counting heuristic blocks any 3-part custom domain like shop.mybrand.com, and (2) hooking wu_domain_post_save caused re-fire on every save — async_remove_old_primary_domains clearing the flag would immediately re-promote it.
  • Fix: Switch hook to wu_transition_domain_stage (fires only on actual stage changes) and replace is_main_domain() with an explicit network-host suffix check.
  • Verified: 130 Domain_Manager_Test assertions pass (0 regressions); 6 new targeted tests.

What changed

inc/managers/class-domain-manager.php

  • Changed hook from wu_domain_post_save to wu_transition_domain_stage
  • Updated method signature to ($old_stage, $new_stage, $domain_id)
  • Added guard: skip if $old_stage was already a done stage
  • Replaced is_main_domain() with network-host suffix check

tests/WP_Ultimo/Managers/Domain_Manager_Test.php

  • 6 new tests: 2-part domain, 3-part custom domain, already-primary guard, existing-primary guard, WP network subdomain exclusion, done-without-ssl stage

Resolves #965 (follow-up fix)


aidevops.sh v3.13.10 plugin for OpenCode v1.3.17 with claude-sonnet-4-6 spent 22m and 7,279 tokens on this with the user in an interactive session.

…part domains

The wu_transition_domain_stage hook replaces the previous wu_domain_post_save
hook, which was re-firing on every save (including async_remove_old_primary_domains
clearing the flag), causing the domain to be immediately re-promoted.

The is_main_domain() TLD-counting heuristic (2-part = custom, 3-part = subdomain)
incorrectly blocked promotion of legitimate 3-part custom domains such as
shop.mybrand.com or prosite.example.com. Replaced with an explicit check against
the WP network host so only native WP multisite subdomains (site.kursopro.com
when network is kursopro.com) are excluded.

Fixes: checklist item 5 (primary_domain=1 auto on DNS verify)
Refs: #965 (original implementation)
@coderabbitai

coderabbitai Bot commented Apr 29, 2026

Copy link
Copy Markdown
Contributor

Warning

Rate limit exceeded

@superdav42 has exceeded the limit for the number of commits that can be reviewed per hour. Please wait 25 minutes and 45 seconds before requesting another review.

To keep reviews running without waiting, you can enable usage-based add-on for your organization. This allows additional reviews beyond the hourly cap. Account admins can enable it under billing.

⌛ How to resolve this issue?

After the wait time has elapsed, a review can be triggered using the @coderabbitai review command as a PR comment. Alternatively, push new commits to this PR.

We recommend that you space out your commits to avoid hitting the rate limit.

🚦 How do rate limits work?

CodeRabbit enforces hourly rate limits for each developer per organization.

Our paid plans have higher rate limits than the trial, open-source and free plans. In all cases, we re-allow further reviews after a brief timeout.

Please see our FAQ for further information.

ℹ️ Review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro

Run ID: aebaad1e-a799-4f07-bd58-31aa0e5a632f

📥 Commits

Reviewing files that changed from the base of the PR and between ad905f9 and c1d6dc0.

📒 Files selected for processing (2)
  • inc/managers/class-domain-manager.php
  • tests/WP_Ultimo/Managers/Domain_Manager_Test.php
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch fix/domain-auto-promote-is-main-domain

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share
Review rate limit: 0/1 reviews remaining, refill in 25 minutes and 45 seconds.

Comment @coderabbitai help to get the list of available commands and usage tips.

@github-actions

Copy link
Copy Markdown

🔨 Build Complete - Ready for Testing!

📦 Download Build Artifact (Recommended)

Download the zip build, upload to WordPress and test:

🌐 Test in WordPress Playground (Very Experimental)

Click the link below to instantly test this PR in your browser - no installation needed!
Playground support for multisite is very limitied, hopefully it will get better in the future.

🚀 Launch in Playground

Login credentials: admin / password

@github-actions

Copy link
Copy Markdown

Performance Test Results

Performance test results for 46571dd are in 🛎️!

Note: the numbers in parentheses show the difference to the previous (baseline) test run. Differences below 2% or 0.5 in absolute values are not shown.

URL: /

Run DB Queries Memory Before Template Template WP Total LCP TTFB LCP - TTFB
0 40 (-1 / -3% ) 37.75 MB 871.00 ms (+25.50 ms / +3% ) 156.00 ms (-9.50 ms / -6% ) 1100.00 ms (+69.00 ms / +6% ) 2028.00 ms 1937.95 ms 93.30 ms
1 56 49.03 MB 962.50 ms (+33.50 ms / +3% ) 151.00 ms (+5.00 ms / +3% ) 1118.50 ms (+43.50 ms / +4% ) 2104.00 ms (+84.00 ms / +4% ) 2023.95 ms (+89.25 ms / +4% ) 83.00 ms (+2.45 ms / +3% )

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.

1 participant