Ensure invariant properties return the correct cache value at source level (#15145)
Co-authored-by: Bjarke Berg <mail@bergmania.dk>
This commit is contained in:
committed by
Bjarke Berg
parent
d35c6f0e94
commit
80fac866c9
@@ -25,6 +25,7 @@ internal class Property : PublishedPropertyBase
|
||||
// the invariant-neutral source and inter values
|
||||
private readonly object? _sourceValue;
|
||||
private readonly ContentVariation _variations;
|
||||
private bool _sourceValueIsInvariant;
|
||||
|
||||
// the variant and non-variant object values
|
||||
private CacheValues? _cacheValues;
|
||||
@@ -89,6 +90,7 @@ internal class Property : PublishedPropertyBase
|
||||
// this variable is used for contextualizing the variation level when calculating property values.
|
||||
// it must be set to the union of variance (the combination of content type and property type variance).
|
||||
_variations = propertyType.Variations | content.ContentType.Variations;
|
||||
_sourceValueIsInvariant = propertyType.Variations is ContentVariation.Nothing;
|
||||
}
|
||||
|
||||
// clone for previewing as draft a published content that is published and has no draft
|
||||
@@ -104,6 +106,7 @@ internal class Property : PublishedPropertyBase
|
||||
_isMember = origin._isMember;
|
||||
_publishedSnapshotAccessor = origin._publishedSnapshotAccessor;
|
||||
_variations = origin._variations;
|
||||
_sourceValueIsInvariant = origin._sourceValueIsInvariant;
|
||||
}
|
||||
|
||||
// used to cache the CacheValues of this property
|
||||
@@ -152,7 +155,7 @@ internal class Property : PublishedPropertyBase
|
||||
{
|
||||
_content.VariationContextAccessor.ContextualizeVariation(_variations, _content.Id, ref culture, ref segment);
|
||||
|
||||
if (culture == string.Empty && segment == string.Empty)
|
||||
if (_sourceValueIsInvariant || (culture == string.Empty && segment == string.Empty))
|
||||
{
|
||||
return _sourceValue;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user