From d9c3ebdfe80b570777943633e9b97176b002e342 Mon Sep 17 00:00:00 2001 From: Sven Geusens Date: Wed, 9 Aug 2023 13:11:44 +0200 Subject: [PATCH] Bugfix 31584 - Remove Lazy "caching" that retains keys of deleted ContentTypes which causes unecesary validation errors (#14643) The validation errors should not happen as the model mapping cleans up block data for entity types that do not longer exist (which is checked on the aformentioned key) Co-authored-by: Sven Geusens --- .../PropertyEditors/BlockEditorValues.cs | 10 +++------- 1 file changed, 3 insertions(+), 7 deletions(-) diff --git a/src/Umbraco.Infrastructure/PropertyEditors/BlockEditorValues.cs b/src/Umbraco.Infrastructure/PropertyEditors/BlockEditorValues.cs index 8b164557b3..773b9e3a62 100644 --- a/src/Umbraco.Infrastructure/PropertyEditors/BlockEditorValues.cs +++ b/src/Umbraco.Infrastructure/PropertyEditors/BlockEditorValues.cs @@ -14,14 +14,14 @@ namespace Umbraco.Cms.Core.PropertyEditors; /// internal class BlockEditorValues { - private readonly Lazy> _contentTypes; private readonly BlockEditorDataConverter _dataConverter; + private readonly IContentTypeService _contentTypeService; private readonly ILogger _logger; public BlockEditorValues(BlockEditorDataConverter dataConverter, IContentTypeService contentTypeService, ILogger logger) { - _contentTypes = new Lazy>(() => contentTypeService.GetAll().ToDictionary(c => c.Key)); _dataConverter = dataConverter; + _contentTypeService = contentTypeService; _logger = logger; } @@ -66,11 +66,7 @@ internal class BlockEditorValues return blockEditorData; } - private IContentType? GetElementType(BlockItemData item) - { - _contentTypes.Value.TryGetValue(item.ContentTypeKey, out IContentType? contentType); - return contentType; - } + private IContentType? GetElementType(BlockItemData item) => _contentTypeService.Get(item.ContentTypeKey); private bool ResolveBlockItemData(BlockItemData block, Dictionary> contentTypePropertyTypes) {