From 3caecf516126570d73c4bd7c01a173b3b87c14e5 Mon Sep 17 00:00:00 2001 From: Claus Date: Thu, 7 Sep 2017 12:57:06 +0200 Subject: [PATCH 1/2] U4-10384 Error when changing content type on media item --- src/Umbraco.Core/Models/PropertyCollection.cs | 1 + 1 file changed, 1 insertion(+) diff --git a/src/Umbraco.Core/Models/PropertyCollection.cs b/src/Umbraco.Core/Models/PropertyCollection.cs index 67a6914739..21c7bf5efc 100644 --- a/src/Umbraco.Core/Models/PropertyCollection.cs +++ b/src/Umbraco.Core/Models/PropertyCollection.cs @@ -95,6 +95,7 @@ namespace Umbraco.Core.Models var property = this[key]; if (item.Value == null && property.Value != null) { + item.Id = property.Id; item.Value = property.Value; } From 598944d3d83753d2e2051a0bdbe3edf50ddb39e2 Mon Sep 17 00:00:00 2001 From: Claus Date: Thu, 7 Sep 2017 13:13:03 +0200 Subject: [PATCH 2/2] ensuring id is only set if unset. --- src/Umbraco.Core/Models/PropertyCollection.cs | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/src/Umbraco.Core/Models/PropertyCollection.cs b/src/Umbraco.Core/Models/PropertyCollection.cs index 21c7bf5efc..efa5111ecb 100644 --- a/src/Umbraco.Core/Models/PropertyCollection.cs +++ b/src/Umbraco.Core/Models/PropertyCollection.cs @@ -93,9 +93,12 @@ namespace Umbraco.Core.Models //NOTE: Consider checking type before value is set: item.PropertyType.DataTypeId == property.PropertyType.DataTypeId //Transfer the existing value to the new property var property = this[key]; - if (item.Value == null && property.Value != null) + if (item.Id == 0 && property.Id != 0) { item.Id = property.Id; + } + if (item.Value == null && property.Value != null) + { item.Value = property.Value; }