Add check for ContentVariation.Nothing when copying documents. (#15185)
A new check for ContentVariation.Nothing is necessary when copying from documents to ensure that if there is no content variation as defined by the Nothing property, values are still copied even if variation is not supported since the content itself will not vary.
This commit is contained in:
@@ -174,15 +174,17 @@ public static class ContentRepositoryExtensions
|
||||
foreach (IProperty property in content.Properties)
|
||||
{
|
||||
// each property type may or may not support the variation
|
||||
if (!property.PropertyType?.SupportsVariation(culture, "*", true) ?? false)
|
||||
if ((!property.PropertyType?.SupportsVariation(culture, "*", true) ?? false) &&
|
||||
!(property.PropertyType?.Variations == ContentVariation.Nothing))
|
||||
{
|
||||
continue;
|
||||
}
|
||||
|
||||
foreach (IPropertyValue pvalue in property.Values)
|
||||
{
|
||||
if ((property.PropertyType?.SupportsVariation(pvalue.Culture, pvalue.Segment, true) ?? false) &&
|
||||
(culture == "*" || (pvalue.Culture?.InvariantEquals(culture) ?? false)))
|
||||
if (((property.PropertyType?.SupportsVariation(pvalue.Culture, pvalue.Segment, true) ?? false) &&
|
||||
(culture == "*" || (pvalue.Culture?.InvariantEquals(culture) ?? false))) ||
|
||||
property.PropertyType?.Variations == ContentVariation.Nothing)
|
||||
{
|
||||
property.SetValue(null, pvalue.Culture, pvalue.Segment);
|
||||
}
|
||||
@@ -193,7 +195,8 @@ public static class ContentRepositoryExtensions
|
||||
IPropertyCollection otherProperties = other.Properties;
|
||||
foreach (IProperty otherProperty in otherProperties)
|
||||
{
|
||||
if (!otherProperty?.PropertyType?.SupportsVariation(culture, "*", true) ?? true)
|
||||
if ((!otherProperty?.PropertyType?.SupportsVariation(culture, "*", true) ?? true) &&
|
||||
!(otherProperty?.PropertyType?.Variations == ContentVariation.Nothing))
|
||||
{
|
||||
continue;
|
||||
}
|
||||
@@ -203,8 +206,9 @@ public static class ContentRepositoryExtensions
|
||||
{
|
||||
foreach (IPropertyValue pvalue in otherProperty.Values)
|
||||
{
|
||||
if (otherProperty.PropertyType.SupportsVariation(pvalue.Culture, pvalue.Segment, true) &&
|
||||
(culture == "*" || (pvalue.Culture?.InvariantEquals(culture) ?? false)))
|
||||
if (((otherProperty?.PropertyType.SupportsVariation(pvalue.Culture, pvalue.Segment, true) ?? false) &&
|
||||
(culture == "*" ||(pvalue.Culture?.InvariantEquals(culture) ?? false))) ||
|
||||
otherProperty?.PropertyType?.Variations == ContentVariation.Nothing)
|
||||
{
|
||||
var value = published ? pvalue.PublishedValue : pvalue.EditedValue;
|
||||
content.SetValue(alias, value, pvalue.Culture, pvalue.Segment);
|
||||
|
||||
Reference in New Issue
Block a user