From 3932ec0640b4cef55bec1c7737be0f4c4fbc5469 Mon Sep 17 00:00:00 2001 From: Shannon Date: Fri, 10 Aug 2018 15:39:57 +1000 Subject: [PATCH] Fixes how invariant property are processed during saving on the server side. --- .../imagecropper/imagecropper.html | 1 - src/Umbraco.Web/Editors/ContentController.cs | 16 +++++++++++++++- 2 files changed, 15 insertions(+), 2 deletions(-) diff --git a/src/Umbraco.Web.UI.Client/src/views/propertyeditors/imagecropper/imagecropper.html b/src/Umbraco.Web.UI.Client/src/views/propertyeditors/imagecropper/imagecropper.html index 7b4287ba5a..bc84f1b64f 100644 --- a/src/Umbraco.Web.UI.Client/src/views/propertyeditors/imagecropper/imagecropper.html +++ b/src/Umbraco.Web.UI.Client/src/views/propertyeditors/imagecropper/imagecropper.html @@ -36,7 +36,6 @@
-
{{model.value.focalPoint | json}}
diff --git a/src/Umbraco.Web/Editors/ContentController.cs b/src/Umbraco.Web/Editors/ContentController.cs index 869c12d85b..ac6048bee2 100644 --- a/src/Umbraco.Web/Editors/ContentController.cs +++ b/src/Umbraco.Web/Editors/ContentController.cs @@ -1251,6 +1251,8 @@ namespace Umbraco.Web.Editors //inline method to determine if a property type varies bool Varies(Property property) => property.PropertyType.VariesByCulture(); + var variantIndex = 0; + //loop through each variant, set the correct name and property values foreach (var variant in contentSave.Variants) { @@ -1272,12 +1274,24 @@ namespace Umbraco.Web.Editors } } + //This is important! We only want to process invariant properties with the first variant, for any other variant + // we need to exclude invariant properties from being processed, otherwise they will be double processed for the + // same value which can cause some problems with things such as file uploads. + var propertyCollection = variantIndex == 0 + ? variant.PropertyCollectionDto + : new ContentPropertyCollectionDto + { + Properties = variant.PropertyCollectionDto.Properties.Where(x => !x.Culture.IsNullOrWhiteSpace()) + }; + //for each variant, map the property values MapPropertyValuesForPersistence( contentSave, - variant.PropertyCollectionDto, + propertyCollection, (save, property) => Varies(property) ? property.GetValue(variant.Culture) : property.GetValue(), //get prop val (save, property, v) => { if (Varies(property)) property.SetValue(v, variant.Culture); else property.SetValue(v); }); //set prop val + + variantIndex++; } //TODO: We need to support 'send to publish'