From 49022cd1b5f486c4dc0cbab8543e99fa0485d6e3 Mon Sep 17 00:00:00 2001 From: Lombiq Date: Thu, 18 Feb 2016 16:32:16 +0100 Subject: [PATCH] To the previous: also caring about the case when ShapePart was dynamically added to the content type/item, see #6360 --- .../Modules/Orchard.Templates/Drivers/TitlePartDriver.cs | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/src/Orchard.Web/Modules/Orchard.Templates/Drivers/TitlePartDriver.cs b/src/Orchard.Web/Modules/Orchard.Templates/Drivers/TitlePartDriver.cs index 7ee00ab15..2a7b6c37c 100644 --- a/src/Orchard.Web/Modules/Orchard.Templates/Drivers/TitlePartDriver.cs +++ b/src/Orchard.Web/Modules/Orchard.Templates/Drivers/TitlePartDriver.cs @@ -28,11 +28,14 @@ namespace Orchard.Templates.Drivers { var contentTypesWithShapePart = _contentManager .GetContentTypeDefinitions() .Where(typeDefinition => typeDefinition.Parts.Any(partDefinition => partDefinition.PartDefinition.Name == "ShapePart")) - .Select(typeDefinition => typeDefinition.Name) - .ToArray(); + .Select(typeDefinition => typeDefinition.Name); + + // If ShapePart is only dynamically added to this content type or even this content item then we won't find + // a corresponding content type definition, so using the current content type too. + contentTypesWithShapePart = contentTypesWithShapePart.Union(new[] { part.ContentItem.ContentType }); var existingShapeCount = _contentManager - .Query(VersionOptions.Latest, contentTypesWithShapePart) + .Query(VersionOptions.Latest, contentTypesWithShapePart.ToArray()) .Where(record => record.Title == part.Title && record.ContentItemRecord.Id != part.ContentItem.Id) .Count();