From 0a10df36465c7f9f1195a87daacb6df7b9bda3d9 Mon Sep 17 00:00:00 2001 From: jtkech Date: Wed, 21 Jun 2023 05:52:30 +0200 Subject: [PATCH 1/3] Only get definitions of provided contained types --- .../Drivers/ContainedPartDisplayDriver.cs | 16 +++++----------- 1 file changed, 5 insertions(+), 11 deletions(-) diff --git a/src/OrchardCore.Modules/OrchardCore.Lists/Drivers/ContainedPartDisplayDriver.cs b/src/OrchardCore.Modules/OrchardCore.Lists/Drivers/ContainedPartDisplayDriver.cs index 6b6372f8c57..26b725cddf6 100644 --- a/src/OrchardCore.Modules/OrchardCore.Lists/Drivers/ContainedPartDisplayDriver.cs +++ b/src/OrchardCore.Modules/OrchardCore.Lists/Drivers/ContainedPartDisplayDriver.cs @@ -164,16 +164,10 @@ private IDisplayResult GetListPartHeader(string containerId, ListPartSettings li }).Location("Content:1"); } - private IEnumerable GetContainedContentTypes(ListPartSettings settings) - { - var contentTypes = settings.ContainedContentTypes ?? Enumerable.Empty(); - - if (!contentTypes.Any()) - { - return Enumerable.Empty(); - } - - return _contentDefinitionManager.ListTypeDefinitions().Where(x => contentTypes.Contains(x.Name)); - } + private IEnumerable GetContainedContentTypes(ListPartSettings settings) => + settings.ContainedContentTypes + ?.Where(contentType => !String.IsNullOrEmpty(contentType)) + .Select(contentType => _contentDefinitionManager.GetTypeDefinition(contentType)) + ?? Enumerable.Empty(); } } From 53eef59256ec06d31a78234d8edde7baf17ba3a1 Mon Sep 17 00:00:00 2001 From: jtkech Date: Wed, 21 Jun 2023 05:58:48 +0200 Subject: [PATCH 2/3] Additional null check --- .../OrchardCore.Lists/Drivers/ContainedPartDisplayDriver.cs | 1 + 1 file changed, 1 insertion(+) diff --git a/src/OrchardCore.Modules/OrchardCore.Lists/Drivers/ContainedPartDisplayDriver.cs b/src/OrchardCore.Modules/OrchardCore.Lists/Drivers/ContainedPartDisplayDriver.cs index 26b725cddf6..d413f1e183f 100644 --- a/src/OrchardCore.Modules/OrchardCore.Lists/Drivers/ContainedPartDisplayDriver.cs +++ b/src/OrchardCore.Modules/OrchardCore.Lists/Drivers/ContainedPartDisplayDriver.cs @@ -168,6 +168,7 @@ private IDisplayResult GetListPartHeader(string containerId, ListPartSettings li settings.ContainedContentTypes ?.Where(contentType => !String.IsNullOrEmpty(contentType)) .Select(contentType => _contentDefinitionManager.GetTypeDefinition(contentType)) + .Where(definition => definition is not null) ?? Enumerable.Empty(); } } From 78efd46f050c0852688e64a5125e39c8b699ddce Mon Sep 17 00:00:00 2001 From: jtkech Date: Wed, 21 Jun 2023 06:19:23 +0200 Subject: [PATCH 3/3] Remove one null check --- .../OrchardCore.Lists/Drivers/ContainedPartDisplayDriver.cs | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/src/OrchardCore.Modules/OrchardCore.Lists/Drivers/ContainedPartDisplayDriver.cs b/src/OrchardCore.Modules/OrchardCore.Lists/Drivers/ContainedPartDisplayDriver.cs index d413f1e183f..0a5bd4467c2 100644 --- a/src/OrchardCore.Modules/OrchardCore.Lists/Drivers/ContainedPartDisplayDriver.cs +++ b/src/OrchardCore.Modules/OrchardCore.Lists/Drivers/ContainedPartDisplayDriver.cs @@ -166,8 +166,7 @@ private IDisplayResult GetListPartHeader(string containerId, ListPartSettings li private IEnumerable GetContainedContentTypes(ListPartSettings settings) => settings.ContainedContentTypes - ?.Where(contentType => !String.IsNullOrEmpty(contentType)) - .Select(contentType => _contentDefinitionManager.GetTypeDefinition(contentType)) + ?.Select(contentType => _contentDefinitionManager.GetTypeDefinition(contentType)) .Where(definition => definition is not null) ?? Enumerable.Empty(); }