Creating a "System" content type breaks Umbraco (#9005)

This commit is contained in:
Kenn Jacobsen
2020-10-12 17:10:22 +02:00
committed by GitHub
parent e5fcfea764
commit e0eadf2cf5

View File

@@ -1,4 +1,5 @@
using System.Collections.Generic;
using System;
using System.Collections.Generic;
using System.ComponentModel.DataAnnotations;
using System.Linq;
using Umbraco.Core;
@@ -25,6 +26,13 @@ namespace Umbraco.ModelsBuilder.Embedded.BackOffice
//don't do anything if we're not enabled
if (!_config.Enable) yield break;
//list of reserved/disallowed aliases for content/media/member types - more can be added as the need arises
var reservedModelAliases = new[] { "system" };
if(reservedModelAliases.Contains(model.Alias, StringComparer.OrdinalIgnoreCase))
{
yield return new ValidationResult($"The model alias {model.Alias} is a reserved term and cannot be used", new[] { "Alias" });
}
var properties = model.Groups.SelectMany(x => x.Properties)
.Where(x => x.Inherited == false)
.ToArray();