URL Info: Fix invariant content URLs missing under non-default language domains (closes #21866)#21883
Conversation
There was a problem hiding this comment.
Pull request overview
Fixes a regression in the Management API/backoffice URL listing where invariant content under a domain assigned to a non-default culture could end up with missing/incorrect URLs, by changing how PublishedUrlInfoProvider enumerates cultures and filters results.
Changes:
- Update
PublishedUrlInfoProvider.GetAllAsyncto iterate all cultures for invariant content, skip missing URLs, and filter out “fallback” base-URL results when domain-based URLs exist. - Add an integration test covering invariant content under a non-default language domain, and rename/keep the existing invariant-no-domain coverage.
- Consolidate the
HideTopLevelNodeFromPath = falsetest into the mainPublishedUrlInfoProviderTestsusingConfigureBuilder.
Reviewed changes
Copilot reviewed 3 out of 3 changed files in this pull request and generated 4 comments.
| File | Description |
|---|---|
| src/Umbraco.Core/Routing/PublishedUrlInfoProvider.cs | Adjusts invariant URL enumeration/filtering logic to surface domain URLs under non-default cultures. |
| tests/Umbraco.Tests.Integration/Umbraco.Core/Services/PublishedUrlInfoProviderTests.cs | Adds/updates integration tests for invariant URL behavior and consolidates HideTopLevel=false coverage. |
| tests/Umbraco.Tests.Integration/Umbraco.Core/Services/PublishedUrlInfoProvider_hidetoplevel_false.cs | Removes the now-redundant separate test fixture after consolidation. |
|
@AndyButland private async Task<IEnumerable<string>> GetCulturesForUrlLookupAsync(IContent content)
{
if (content.ContentType.VariesByCulture())
{
return await _languageService.GetAllIsoCodesAsync();
}
IUmbracoContext umbracoContext = _umbracoContextAccessor.GetRequiredUmbracoContext();
var ancestorOrSelfIds = content.AncestorIds().Append(content.Id).ToHashSet();
var domainCultures = umbracoContext.Domains.GetAll(true)
.Where(d => ancestorOrSelfIds.Contains(d.ContentId))
.Select(d => d.Culture)
.WhereNotNull()
.Distinct(StringComparer.OrdinalIgnoreCase)
.ToList();
return domainCultures.Count > 0
? domainCultures
: [await _languageService.GetDefaultIsoCodeAsync()];
}Which could then be assigned to |
|
I think this looks OK @lauraneto - and I can see the benefit of getting the cultures up front rather than handling the duplications later. Please go ahead if you'd like to update this. |
Instead of querying all cultures and post-processing to remove irrelevant URLs, determine the relevant cultures before the loop by checking which domains are assigned to the content's ancestor path.
…ge domains (closes #21866) (#21883) * Show correct URLs for invariant content under non-default language domains. * Use configured domain hosts instead of request host for fallback URL filtering. * Addressed feedback from code review. * Fixed code warnings. * Update file references in integration test csproj. * Simplify invariant URL culture filtering by determining cultures upfront Instead of querying all cultures and post-processing to remove irrelevant URLs, determine the relevant cultures before the loop by checking which domains are assigned to the content's ancestor path. --------- Co-authored-by: Laura Neto <[email protected]>
|
Cherry-picked to |
Updated [Umbraco.Cms](https://github.com/umbraco/Umbraco-CMS) from 17.2.0 to 17.2.1. <details> <summary>Release notes</summary> _Sourced from [Umbraco.Cms's releases](https://github.com/umbraco/Umbraco-CMS/releases)._ ## 17.2.1 ## What's Changed ### 🐛 Bug Fixes * URL Info: Fix invariant content URLs missing under non-default language domains (closes #21866) by @AndyButland in umbraco/Umbraco-CMS#21883 * Database Cache: Fix full database cache rebuild dropping variant and composed property values (closes #21863, #21882) by @AndyButland in umbraco/Umbraco-CMS#21890 **Full Changelog**: umbraco/Umbraco-CMS@release-17.2.0...release-17.2.1 Commits viewable in [compare view](umbraco/Umbraco-CMS@release-17.2.0...release-17.2.1). </details> Updated [Umbraco.Cms.Persistence.Sqlite](https://github.com/umbraco/Umbraco-CMS) from 17.2.0 to 17.2.1. <details> <summary>Release notes</summary> _Sourced from [Umbraco.Cms.Persistence.Sqlite's releases](https://github.com/umbraco/Umbraco-CMS/releases)._ ## 17.2.1 ## What's Changed ### 🐛 Bug Fixes * URL Info: Fix invariant content URLs missing under non-default language domains (closes #21866) by @AndyButland in umbraco/Umbraco-CMS#21883 * Database Cache: Fix full database cache rebuild dropping variant and composed property values (closes #21863, #21882) by @AndyButland in umbraco/Umbraco-CMS#21890 **Full Changelog**: umbraco/Umbraco-CMS@release-17.2.0...release-17.2.1 Commits viewable in [compare view](umbraco/Umbraco-CMS@release-17.2.0...release-17.2.1). </details> Dependabot will resolve any conflicts with this PR as long as you don't alter it yourself. You can also trigger a rebase manually by commenting `@dependabot rebase`. [//]: # (dependabot-automerge-start) [//]: # (dependabot-automerge-end) --- <details> <summary>Dependabot commands and options</summary> <br /> You can trigger Dependabot actions by commenting on this PR: - `@dependabot rebase` will rebase this PR - `@dependabot recreate` will recreate this PR, overwriting any edits that have been made to it - `@dependabot show <dependency name> ignore conditions` will show all of the ignore conditions of the specified dependency - `@dependabot ignore this major version` will close this PR and stop Dependabot creating any more for this major version (unless you reopen the PR or upgrade to it yourself) - `@dependabot ignore this minor version` will close this PR and stop Dependabot creating any more for this minor version (unless you reopen the PR or upgrade to it yourself) - `@dependabot ignore this dependency` will close this PR and stop Dependabot creating any more for this dependency (unless you reopen the PR or upgrade to it yourself) </details> Signed-off-by: dependabot[bot] <[email protected]> Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
Updated [Umbraco.Cms.DevelopmentMode.Backoffice](https://github.com/umbraco/Umbraco-CMS) from 17.2.0 to 17.2.1. <details> <summary>Release notes</summary> _Sourced from [Umbraco.Cms.DevelopmentMode.Backoffice's releases](https://github.com/umbraco/Umbraco-CMS/releases)._ ## 17.2.1 ## What's Changed ### 🐛 Bug Fixes * URL Info: Fix invariant content URLs missing under non-default language domains (closes #21866) by @AndyButland in umbraco/Umbraco-CMS#21883 * Database Cache: Fix full database cache rebuild dropping variant and composed property values (closes #21863, #21882) by @AndyButland in umbraco/Umbraco-CMS#21890 **Full Changelog**: umbraco/Umbraco-CMS@release-17.2.0...release-17.2.1 Commits viewable in [compare view](umbraco/Umbraco-CMS@release-17.2.0...release-17.2.1). </details> [](https://docs.github.com/en/github/managing-security-vulnerabilities/about-dependabot-security-updates#about-compatibility-scores) Dependabot will resolve any conflicts with this PR as long as you don't alter it yourself. You can also trigger a rebase manually by commenting `@dependabot rebase`. [//]: # (dependabot-automerge-start) [//]: # (dependabot-automerge-end) --- <details> <summary>Dependabot commands and options</summary> <br /> You can trigger Dependabot actions by commenting on this PR: - `@dependabot rebase` will rebase this PR - `@dependabot recreate` will recreate this PR, overwriting any edits that have been made to it - `@dependabot show <dependency name> ignore conditions` will show all of the ignore conditions of the specified dependency - `@dependabot ignore this major version` will close this PR and stop Dependabot creating any more for this major version (unless you reopen the PR or upgrade to it yourself) - `@dependabot ignore this minor version` will close this PR and stop Dependabot creating any more for this minor version (unless you reopen the PR or upgrade to it yourself) - `@dependabot ignore this dependency` will close this PR and stop Dependabot creating any more for this dependency (unless you reopen the PR or upgrade to it yourself) </details> Signed-off-by: dependabot[bot] <[email protected]> Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
Description
#21866 reports a regression from #21473 where invariant content under a domain assigned to a non-default culture (e.g.
test.dk→da-DK) showed no URLs in the backoffice Info tab.Now for invariant content, we iterate all cultures and skip those that return no URL (
"#"), as well filtering out fallback URLs (using the request base URL) when domain-based URLs exist. This seems a reasonable approach for invariant content, where we would only expect one language to be defined on a domain setting.I added further integration tests and did a little test clean-up for this class too.
Testing
See the linked issue for a project that can be used to verify the fix. I pulled out just the database and credentials and set up my local test site to point to that.
With this PR in place I now see expected domains under each root node: