From ac8a83177fd177d8dfe6cb22882b8d68e89a4812 Mon Sep 17 00:00:00 2001 From: Nikolaj Date: Thu, 26 Aug 2021 14:21:40 +0200 Subject: [PATCH 1/3] Make AutoInterningStringKeyCaseInsensitiveDictionaryConverter case insensitive Instead of calling the parents CreateDictionary we just newed up a regular dictionary leading to AutoInterningStringKeyCaseInsensitiveDictionaryConverter not actually being case insensitive --- ...utoInterningStringKeyCaseInsensitiveDictionaryConverter.cs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/Umbraco.Core/Serialization/AutoInterningStringKeyCaseInsensitiveDictionaryConverter.cs b/src/Umbraco.Core/Serialization/AutoInterningStringKeyCaseInsensitiveDictionaryConverter.cs index 2076462f0c..f40b4b9f10 100644 --- a/src/Umbraco.Core/Serialization/AutoInterningStringKeyCaseInsensitiveDictionaryConverter.cs +++ b/src/Umbraco.Core/Serialization/AutoInterningStringKeyCaseInsensitiveDictionaryConverter.cs @@ -7,7 +7,7 @@ using Newtonsoft.Json.Converters; namespace Umbraco.Core.Serialization { /// - /// When applied to a dictionary with a string key, will ensure the deserialized string keys are interned + /// When applied to a dictionary with a string key, will ensure the deserialized string keys are interned /// /// /// @@ -26,7 +26,7 @@ namespace Umbraco.Core.Serialization { if (reader.TokenType == JsonToken.StartObject) { - var dictionary = new Dictionary(); + var dictionary = Create(objectType); while (reader.Read()) { switch (reader.TokenType) From 7f279bcd77b0d8f679909b30f62c56282d0c689a Mon Sep 17 00:00:00 2001 From: Nikolaj Date: Tue, 31 Aug 2021 08:30:46 +0200 Subject: [PATCH 2/3] Add messagepack formatter for dictionary with key ignore case This is required for culture since there will be called ToLower on the culture when used as a dictionary key. --- .../DataSource/ContentCacheDataModel.cs | 2 + ...ngKeyCaseInsensitiveDictionaryFormatter.cs | 39 +++++++++++++++++++ src/Umbraco.Web/Umbraco.Web.csproj | 1 + 3 files changed, 42 insertions(+) create mode 100644 src/Umbraco.Web/PublishedCache/NuCache/DataSource/MessagePackAutoInterningStringKeyCaseInsensitiveDictionaryFormatter.cs diff --git a/src/Umbraco.Web/PublishedCache/NuCache/DataSource/ContentCacheDataModel.cs b/src/Umbraco.Web/PublishedCache/NuCache/DataSource/ContentCacheDataModel.cs index 40acdfdb55..de49581730 100644 --- a/src/Umbraco.Web/PublishedCache/NuCache/DataSource/ContentCacheDataModel.cs +++ b/src/Umbraco.Web/PublishedCache/NuCache/DataSource/ContentCacheDataModel.cs @@ -17,11 +17,13 @@ namespace Umbraco.Web.PublishedCache.NuCache.DataSource [DataMember(Order = 0)] [JsonProperty("pd")] [JsonConverter(typeof(AutoInterningStringKeyCaseInsensitiveDictionaryConverter))] + [MessagePackFormatter(typeof(MessagePackAutoInterningStringKeyCaseInsensitiveDictionaryFormatter))] public Dictionary PropertyData { get; set; } [DataMember(Order = 1)] [JsonProperty("cd")] [JsonConverter(typeof(AutoInterningStringKeyCaseInsensitiveDictionaryConverter))] + [MessagePackFormatter(typeof(MessagePackAutoInterningStringKeyCaseInsensitiveDictionaryFormatter))] public Dictionary CultureData { get; set; } [DataMember(Order = 2)] diff --git a/src/Umbraco.Web/PublishedCache/NuCache/DataSource/MessagePackAutoInterningStringKeyCaseInsensitiveDictionaryFormatter.cs b/src/Umbraco.Web/PublishedCache/NuCache/DataSource/MessagePackAutoInterningStringKeyCaseInsensitiveDictionaryFormatter.cs new file mode 100644 index 0000000000..24691497bc --- /dev/null +++ b/src/Umbraco.Web/PublishedCache/NuCache/DataSource/MessagePackAutoInterningStringKeyCaseInsensitiveDictionaryFormatter.cs @@ -0,0 +1,39 @@ +using System; +using System.Collections.Generic; +using MessagePack; +using MessagePack.Formatters; + +namespace Umbraco.Web.PublishedCache.NuCache.DataSource +{ + /// + /// A messagepack formatter (deserializer) for a string key dictionary that uses OrdinalIgnoreCase for the key string comparison + /// + /// + public sealed class MessagePackAutoInterningStringKeyCaseInsensitiveDictionaryFormatter : DictionaryFormatterBase, Dictionary.Enumerator, Dictionary> + { + protected override void Add(Dictionary collection, int index, string key, TValue value, MessagePackSerializerOptions options) + { + string.Intern(key); + collection.Add(key, value); + } + + protected override Dictionary Complete(Dictionary intermediateCollection) + { + return intermediateCollection; + } + + + protected override Dictionary.Enumerator GetSourceEnumerator(Dictionary source) + { + return source.GetEnumerator(); + } + + protected override Dictionary Create(int count, MessagePackSerializerOptions options) + { + return new Dictionary(count, StringComparer.OrdinalIgnoreCase); + } + } +} + + + diff --git a/src/Umbraco.Web/Umbraco.Web.csproj b/src/Umbraco.Web/Umbraco.Web.csproj index 2340228eae..5f6ab67a42 100644 --- a/src/Umbraco.Web/Umbraco.Web.csproj +++ b/src/Umbraco.Web/Umbraco.Web.csproj @@ -297,6 +297,7 @@ + From f36785f2e83dc889bdc3d92447bc913266433dc2 Mon Sep 17 00:00:00 2001 From: Mads Rasmussen Date: Tue, 31 Aug 2021 13:07:21 +0200 Subject: [PATCH 3/3] fixes: #10373 --- .../src/common/services/blockeditormodelobject.service.js | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/src/Umbraco.Web.UI.Client/src/common/services/blockeditormodelobject.service.js b/src/Umbraco.Web.UI.Client/src/common/services/blockeditormodelobject.service.js index ee96cfbaaa..45dacfd0d1 100644 --- a/src/Umbraco.Web.UI.Client/src/common/services/blockeditormodelobject.service.js +++ b/src/Umbraco.Web.UI.Client/src/common/services/blockeditormodelobject.service.js @@ -606,6 +606,12 @@ return null; } + // the Settings model has been changed to a new Element Type. + // we need to update the settingsData with the new Content Type key + if (settingsData.contentTypeKey !== settingsScaffold.contentTypeKey) { + settingsData.contentTypeKey = settingsScaffold.contentTypeKey; + } + blockObject.settingsData = settingsData; // make basics from scaffold