Segments: Only validate segment values for cultures they are defined for (closes #21029)#21033
Merged
Segments: Only validate segment values for cultures they are defined for (closes #21029)#21033
Conversation
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
…b.com/umbraco/Umbraco-CMS into v17/bugfix/segment-culture-validation
…es provided in the model to determine segments with cultures.
kjac
reviewed
Dec 3, 2025
src/Umbraco.Core/Models/ContentEditing/ContentEditingModelBase.cs
Outdated
Show resolved
Hide resolved
kjac
reviewed
Dec 3, 2025
src/Umbraco.Core/Models/ContentEditing/ContentEditingModelBase.cs
Outdated
Show resolved
Hide resolved
Co-authored-by: Kenn Jacobsen <kja@umbraco.dk>
kjac
approved these changes
Dec 4, 2025
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Prerequisites
Addresses: #21029
Description
This PR adds culture-aware segment validation to skip validating property values for segments not defined a culture.
See the linked issue for details of the concern and how to set up to test.
The issue comes as currently we don't look at what segments are defined when validating - we just take the aliases that come from the model. A defined segment though can have one or more cultures defined for it. If at least one culture is defined, the segment can be created only for those cultures. And as such, we shouldn't validate segments that aren't creatable for a culture.
In the first version of this PR I've resolved this by injecting
ISegmentServiceto determine this.After discussion I've removed this. We currently rely on the incoming model variants and properties to determine the segments, and we can do similar to find the segments along with the cultures they are associated with by looking at what culture and segment combinations are provided.
I've verified that this works for Save, Save and Publish and Publish operations on a document.
There's a small UI issue - that if tackled, should be handled in another PR - in that we still report publishing segments that aren't valid for a culture.
Which comes from this code in
UmbPublishDocumentEntityAction.