Issue #3588176: Allow up to two host wildcards in alias patterns
Summary
Raise the host-wildcard cap in both alias pattern validators (legacy DomainAliasValidator and current DomainAliasPatternConstraintValidator) from 1 to 2. The port wildcard :* continues to be tracked independently and is not counted against the host-wildcard limit (#3588169).
Half-step toward the documented "max 3" claim in the README. Conservative starting point: cap = 2 covers the realistic deployment patterns (e.g. *.*.example.com, *.example.*, example.*.*) without forcing the test surface or operator visibility of a full cap=3 jump. A further raise to cap=3 can land as a follow-up after this has been in the wild.
Issue: #3588176.
Dependency
Depends on #3588175 (DomainAliasPatternResolver substitution hardening), already merged. Without it, allowing multi-host-wildcard source patterns re-introduces the failure modes documented on #3588175 — the resolver would silently produce broken URLs when source/target wildcard counts mismatched. With #3588175 in place, cap=2 is safe.
What ships
| File | Change |
|---|---|
DomainAliasValidator.php |
$host_wildcards > 1 → > 2, message updated. |
DomainAliasPatternConstraintValidator.php |
Same on the entity-constraint side. |
DomainAliasPatternConstraint.php |
multipleWildcardsMessage: "at most two wildcard characters in the hostname portion of an alias." |
DomainAliasForm.php |
Pattern field #description extended with multi-host-wildcard examples. |
README.md |
"At most one wildcard" → "At most two wildcards" in the Constraints subsection; example list extended. |
DomainAliasValidatorTest.php |
Positive cases for *.*.example.com, *.example.*, example.*.*, *.*.example.com:*, *.*.example.com:8080. Negative cases for 3+ host wildcards. |
DomainAliasConstraintTest.php |
testValidPatterns extended with the same combinations. testMultipleWildcards updated to assert the new violation message at 3-host-wildcard input. |
Behavior change
Strict superset; no patterns previously valid are now rejected.
- Patterns previously rejected for having two host wildcards (e.g.
*.*.example.com,*.example.*,example.*.*,*.*.example.com:*) now save successfully. - Patterns with three or more host wildcards remain rejected.
- The port wildcard
:*is unchanged — independent of the host-wildcard cap, single-colon rule still applies.
Note on the README's historical "max 3" claim
The original domain_alias README has documented "max 3 wildcards" since the 8.x-1.x port. One plausible reading of that historical wording is that the "max 3" total counted host stars and the port :* together — e.g. example.*.*.* (3 host wildcards) and *.example.*:* (2 host + 1 port = 3 total) both fit a "≤3 total" cap. This MR sticks with the post-#3588169 model where host and port are tracked independently: the host cap is what's raised here; the port wildcard remains capped separately by the single-colon rule.
Test plan
-
DomainAliasValidatorTest::testDomainAliasValidator— passes locally with the new fixtures. -
DomainAliasConstraintTest(16 tests, 33 assertions) — passes locally. - PHPCS / PHPStan / cspell clean.
- CI phpunit run.
- Spot-check on a multi-alias setup that registering
*.*.example.comand friends now succeeds and that runtime negotiation resolves them as the priority docs added in #3588155 promise.
Out of scope (separate follow-up)
- Raising the host cap to 3 (the full README claim). Defer until cap=2 has shown no regressions in the wild.
- Cross-pattern wildcard-count validation at alias save time (catching mismatches at form-save before they reach the resolver). Tracked separately if desired; the runtime guard from #3588175 already handles this defensively.
Coordination
Sits on top of !370 (merged) (#3588155, merged), !372 (merged) (#3588169, merged), !371 (merged) (#3588168, merged), and !373 (merged) (#3588175, merged). All four prerequisites in place.