Fixes U4-1370 for ContentTypes thats loading using new api meaning that the fix only applies to Content and Media, but currently not Members.
For Members there is still an issue with MasterContentTypes, as the full structure is not loaded. Need to make the sql lookup recursive-
This commit is contained in:
@@ -116,7 +116,7 @@ namespace Umbraco.Core.Models
|
||||
/// <summary>
|
||||
/// Gets a list of ContentType aliases from the current composition
|
||||
/// </summary>
|
||||
/// <returns></returns>
|
||||
/// <returns>An enumerable list of string aliases</returns>
|
||||
/// <remarks>Does not contain the alias of the Current ContentType</remarks>
|
||||
public IEnumerable<string> CompositionAliases()
|
||||
{
|
||||
@@ -124,5 +124,17 @@ namespace Umbraco.Core.Models
|
||||
.Select(x => x.Alias)
|
||||
.Union(ContentTypeComposition.SelectMany(x => x.CompositionAliases()));
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Gets a list of ContentType Ids from the current composition
|
||||
/// </summary>
|
||||
/// <returns>An enumerable list of integer ids</returns>
|
||||
/// <remarks>Does not contain the Id of the Current ContentType</remarks>
|
||||
public IEnumerable<int> CompositionIds()
|
||||
{
|
||||
return ContentTypeComposition
|
||||
.Select(x => x.Id)
|
||||
.Union(ContentTypeComposition.SelectMany(x => x.CompositionIds()));
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -46,7 +46,13 @@ namespace Umbraco.Core.Models
|
||||
/// <summary>
|
||||
/// Gets a list of ContentType aliases from the current composition
|
||||
/// </summary>
|
||||
/// <returns></returns>
|
||||
/// <returns>An enumerable list of string aliases</returns>
|
||||
IEnumerable<string> CompositionAliases();
|
||||
|
||||
/// <summary>
|
||||
/// Gets a list of ContentType Ids from the current composition
|
||||
/// </summary>
|
||||
/// <returns>An enumerable list of integer ids</returns>
|
||||
IEnumerable<int> CompositionIds();
|
||||
}
|
||||
}
|
||||
@@ -130,7 +130,8 @@ namespace umbraco.controls
|
||||
// Iterate through the property types and add them to the tab
|
||||
// zb-00036 #29889 : fix property types getter to get the right set of properties
|
||||
// ge : had a bit of a corrupt db and got weird NRE errors so rewrote this to catch the error and rethrow with detail
|
||||
foreach (PropertyType propertyType in tab.GetPropertyTypes(_content.ContentType.Id))
|
||||
var propertyTypes = tab.GetPropertyTypes(_content.ContentType.Id);
|
||||
foreach (PropertyType propertyType in propertyTypes)
|
||||
{
|
||||
var property = _content.getProperty(propertyType);
|
||||
if (property != null && tabPage != null)
|
||||
|
||||
@@ -582,14 +582,25 @@ namespace umbraco.cms.businesslogic
|
||||
if (m_masterContentTypes == null)
|
||||
{
|
||||
m_masterContentTypes = new List<int>();
|
||||
using (var dr = SqlHelper.ExecuteReader(@"SELECT parentContentTypeId FROM cmsContentType2ContentType WHERE childContentTypeId = @id", SqlHelper.CreateParameter("@id", Id)))
|
||||
if (_contentType == null)
|
||||
{
|
||||
while (dr.Read())
|
||||
//TODO Make this recursive, so it looks up Masters of the Master ContentType
|
||||
using (
|
||||
var dr =
|
||||
SqlHelper.ExecuteReader(
|
||||
@"SELECT parentContentTypeId FROM cmsContentType2ContentType WHERE childContentTypeId = @id",
|
||||
SqlHelper.CreateParameter("@id", Id)))
|
||||
{
|
||||
m_masterContentTypes.Add(dr.GetInt("parentContentTypeId"));
|
||||
while (dr.Read())
|
||||
{
|
||||
m_masterContentTypes.Add(dr.GetInt("parentContentTypeId"));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
else
|
||||
{
|
||||
m_masterContentTypes = _contentType.CompositionIds().ToList();
|
||||
}
|
||||
|
||||
}
|
||||
return m_masterContentTypes;
|
||||
|
||||
Reference in New Issue
Block a user