From 99c96bce86478cd4c5b656a8820db3b15bd294cb Mon Sep 17 00:00:00 2001 From: Stephan Date: Wed, 10 Dec 2014 13:00:56 +0100 Subject: [PATCH] U4-5986 - reject ppty alias used by ancestor --- .../Services/ContentTypeService.cs | 24 +++++++++++++++++++ 1 file changed, 24 insertions(+) diff --git a/src/Umbraco.Core/Services/ContentTypeService.cs b/src/Umbraco.Core/Services/ContentTypeService.cs index ca3261f868..0acbf8b693 100644 --- a/src/Umbraco.Core/Services/ContentTypeService.cs +++ b/src/Umbraco.Core/Services/ContentTypeService.cs @@ -327,6 +327,30 @@ namespace Umbraco.Core.Services string.Join(", ", intersect)); throw new Exception(message); } + + // find all ancestors + var ancestors = new HashSet(comparer); + stack.Clear(); + foreach (var z in compo.ContentTypeComposition) + stack.Push(z); + while (stack.Count > 0) + { + var c = stack.Pop(); + ancestors.Add(c); + foreach (var z in c.ContentTypeComposition) + stack.Push(z); + } + + // ensure that no ancestor has a property with an alias that is used by content type + foreach (var a in ancestors) + { + var intersect = a.PropertyTypes.Select(x => x.Alias.ToLowerInvariant()).Intersect(aliases).ToArray(); + if (intersect.Length == 0) continue; + + var message = string.Format("The following property aliases conflict with ancestors : {0}.", + string.Join(", ", intersect)); + throw new Exception(message); + } } ///