Skip to content

feat(domain-mapping): add runtime URL rewriting - #1736

Draft
superdav42 wants to merge 3 commits into
mainfrom
feature/auto-20260820-180858
Draft

feat(domain-mapping): add runtime URL rewriting#1736
superdav42 wants to merge 3 commits into
mainfrom
feature/auto-20260820-180858

Conversation

@superdav42

@superdav42 superdav42 commented Aug 21, 2026

Copy link
Copy Markdown
Collaborator

Summary

  • add opt-in runtime URL mappings for staging and other environment hostnames
  • treat each configured domain pair as a suffix rule that automatically applies to the root and every nested subdomain
  • preserve leading labels, so customer.example.com maps to customer.staging.example.com from one root rule
  • resolve matching requests against canonical multisite site and network records during Sunrise
  • rewrite generated, rendered, escaped, encoded, upload, REST, and redirect URLs without changing database values
  • support explicit child-domain overrides, path mappings, and ports
  • document configuration, extension hooks, behavior, and proof-of-concept limitations

Configuration

A single pair covers an entire subdomain network:

define('WP_ULTIMO_RUNTIME_URL_FROM', 'https://example.com');
define('WP_ULTIMO_RUNTIME_URL_TO', 'https://staging.example.com');

This maps the roots and preserves arbitrary leading labels, including nested subdomains. WP_ULTIMO_RUNTIME_URL_MAP remains available when a network has multiple unrelated root domains or needs a more specific child override.

Testing

  • vendor/bin/phpunit --no-coverage --filter Runtime_URL_Rewriter_Test — 10 tests, 48 assertions passed
  • suffix coverage includes root domains, ordinary and nested subdomains, escaped and encoded forms, child-rule precedence, target idempotence, dynamic redirect hosts, paths, and port-bearing canonical routing
  • vendor/bin/phpunit --no-coverage --filter 'Domain_Mapping|Sunrise_Test' — 430 tests, 802 assertions passed, with three existing skipped tests
  • vendor/bin/phpcs inc/domain-mapping/class-runtime-url-rewriter.php tests/WP_Ultimo/Domain_Mapping/Runtime_URL_Rewriter_Test.php — passed
  • vendor/bin/phpstan analyse --no-progress inc/domain-mapping/class-runtime-url-rewriter.php tests/WP_Ultimo/Domain_Mapping/Runtime_URL_Rewriter_Test.php — passed
  • WP-CLI multisite integration checks covered canonical site/network routing, paths, ports, and home_url() rewriting
  • full PHPUnit suite completed 10,169 tests and 27,827 assertions; it reported two unrelated existing Self_Boot_Builder_Test environment errors (ValueError: Path must not be empty), plus 55 skipped and one incomplete test

aidevops.sh v3.32.284 plugin for OpenCode v1.18.18 with gpt-5.6-sol spent 23h 31m and 3,099,418 tokens on this with the user in an interactive session.

@superdav42 superdav42 added the origin:interactive Created by interactive user session label Aug 21, 2026
@coderabbitai

coderabbitai Bot commented Aug 21, 2026

Copy link
Copy Markdown
Contributor

Important

Review skipped

Draft detected.

Please check the settings in the CodeRabbit UI or the .coderabbit.yaml file in this repository. To trigger a single review, invoke the @coderabbitai review command.

⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro Plus

Run ID: 0a79e1c9-3dc4-49fb-becb-50f54beb69c7

You can disable this status message by setting the reviews.review_status to false in the CodeRabbit configuration file.

Use the checkbox below for a quick retry:

  • 🔍 Trigger review

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

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

@superdav42

Copy link
Copy Markdown
Collaborator Author

Completion Summary

  • What: Added opt-in runtime-only environment URL routing and rewriting without database mutation.
  • Issue: Direct interactive request; task allocation was unavailable because the repository counter branch is not configured.
  • Files changed: inc/domain-mapping/class-runtime-url-rewriter.php, inc/class-sunrise.php, docs/RUNTIME-URL-REWRITING.md, tests/WP_Ultimo/Domain_Mapping/Runtime_URL_Rewriter_Test.php
  • Testing: Focused PHPUnit passed with 8 tests and 30 assertions; PHPCS and PHPStan passed; WP-CLI multisite integration checks passed; the full 10,169-test suite completed with two unrelated existing site-exporter environment errors.
  • Key decisions: Keep canonical database values unchanged, require exact authority/path boundaries, avoid bare-domain replacement, and initialize routing through Sunrise before normal multisite resolution.

aidevops.sh v3.32.280 plugin for OpenCode v1.18.18 with gpt-5.6-sol spent 7h 51m and 2,190,358 tokens on this with the user in an interactive session.

@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

🔨 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

🔨 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 2a7ffb7 are in 🛎️!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

origin:interactive Created by interactive user session

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant