From ce372abf8a87398e0a8d485f86caf00567e9ef73 Mon Sep 17 00:00:00 2001 From: Ethan Nagano <50598649+nagolucky18@users.noreply.github.com> Date: Mon, 25 Mar 2024 06:27:36 -0700 Subject: [PATCH] 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. --- .../Models/ContentRepositoryExtensions.cs | 16 ++++++++++------ 1 file changed, 10 insertions(+), 6 deletions(-) diff --git a/src/Umbraco.Core/Models/ContentRepositoryExtensions.cs b/src/Umbraco.Core/Models/ContentRepositoryExtensions.cs index 5b7d68a72b..24fd7847b4 100644 --- a/src/Umbraco.Core/Models/ContentRepositoryExtensions.cs +++ b/src/Umbraco.Core/Models/ContentRepositoryExtensions.cs @@ -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);