Skip to content

Routing: Fix URL aliases not stored for variant content with shared alias property in DocumentUrlAliasService#21571

Merged
AndyButland merged 2 commits intorelease/17.2from
v17/bugfix/alias-cache-with-shared-properties
Feb 4, 2026
Merged

Routing: Fix URL aliases not stored for variant content with shared alias property in DocumentUrlAliasService#21571
AndyButland merged 2 commits intorelease/17.2from
v17/bugfix/alias-cache-with-shared-properties

Conversation

@AndyButland
Copy link
Contributor

@AndyButland AndyButland commented Jan 29, 2026

Description

This fixes a bug found in testing of the document URL alias service, introduced as an optimisation for finding documents by URL alias in #21396.

I found URL aliases were not being stored for variant content types that have a shared (non-culture-varied) umbracoUrlAlias property.

The service now checks if the alias property itself varies by culture, not just the content type, which fixes this issue.

Root Cause

ExtractAliasesFromDocumentAsync only checked if the content type varies by culture. For variant content types, it always called document.GetValue<string>(alias, culture) with a culture parameter. However, for shared properties, this returns null because shared properties don't have culture-specific values.

Fix

Check if the umbracoUrlAlias property itself varies by culture:

  • Invariant content type → Get value without culture ✓
  • Variant content type + shared alias property → Get value without culture ✓ (fixed)
  • Variant content type + variant alias property → Get value with culture ✓

Testing

For manual verification, create a variant document type with a shared, text string property with an alias of umbracoUrlAlias.
Create a document of that type, populate the property and verify it has been recorded in umbracoDocumentUrlAlias.

An integration test has been added that verifies this behaviour.

Copilot AI review requested due to automatic review settings January 29, 2026 12:11
Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Fixes URL aliases not being stored for culture-variant content types when the umbracoUrlAlias property itself is shared (invariant), by checking property-level variation rather than only content-type variation.

Changes:

  • Update DocumentUrlAliasService.ExtractAliasesFromDocumentAsync to read umbracoUrlAlias without culture when the property does not vary by culture (even if the content type does).
  • Add integration tests covering both variant-alias and shared-alias scenarios on culture-variant content types.
  • Update tests to use ITemplateService.CreateAsync instead of the obsolete IFileService.SaveTemplate.

Reviewed changes

Copilot reviewed 2 out of 2 changed files in this pull request and generated 2 comments.

File Description
src/Umbraco.Core/Services/DocumentUrlAliasService.cs Determines alias culture-variance from the umbracoUrlAlias property type and stores aliases accordingly.
tests/Umbraco.Tests.Integration/Umbraco.Core/Services/DocumentUrlAliasServiceTests.cs Adds integration test coverage for variant content types with shared vs culture-varied alias properties; updates template creation to ITemplateService.

Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
@AndyButland AndyButland changed the title DocumentUrlAliasService: Fix URL aliases not stored for variant content with shared alias property Routing: Fix URL aliases not stored for variant content with shared alias property in DocumentUrlAliasService Jan 29, 2026
Copy link
Member

@Zeegaan Zeegaan left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good, tests good 🚀

@AndyButland AndyButland merged commit 2917e5b into release/17.2 Feb 4, 2026
23 of 24 checks passed
@AndyButland AndyButland deleted the v17/bugfix/alias-cache-with-shared-properties branch February 4, 2026 08:54
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants