U4-7108 - fix ContentTypeService.GetMediaType(guid)
This commit is contained in:
@@ -1070,6 +1070,11 @@ AND umbracoNode.id <> @id",
|
||||
out IDictionary<int, PropertyTypeCollection> allPropertyTypeCollection,
|
||||
out IDictionary<int, PropertyGroupCollection> allPropertyGroupCollection)
|
||||
{
|
||||
allPropertyGroupCollection = new Dictionary<int, PropertyGroupCollection>();
|
||||
allPropertyTypeCollection = new Dictionary<int, PropertyTypeCollection>();
|
||||
|
||||
// query below is not safe + pointless if array is empty
|
||||
if (contentTypeIds.Length == 0) return;
|
||||
|
||||
// first part Gets all property groups including property type data even when no property type exists on the group
|
||||
// second part Gets all property types including ones that are not on a group
|
||||
@@ -1105,10 +1110,8 @@ AND umbracoNode.id <> @id",
|
||||
INNER JOIN cmsDataType as DT
|
||||
ON PT.dataTypeId = DT.nodeId
|
||||
LEFT JOIN cmsPropertyTypeGroup as PG
|
||||
ON PG.id = PT.propertyTypeGroupId");
|
||||
|
||||
if (contentTypeIds.Any())
|
||||
sqlBuilder.AppendLine(" WHERE (PT.contentTypeId in (@contentTypeIds))");
|
||||
ON PG.id = PT.propertyTypeGroupId
|
||||
WHERE (PT.contentTypeId in (@contentTypeIds))");
|
||||
|
||||
sqlBuilder.AppendLine(" ORDER BY (pgId)");
|
||||
|
||||
@@ -1119,9 +1122,6 @@ AND umbracoNode.id <> @id",
|
||||
|
||||
var result = db.Fetch<dynamic>(sqlBuilder.ToString(), new { contentTypeIds = contentTypeIds });
|
||||
|
||||
allPropertyGroupCollection = new Dictionary<int, PropertyGroupCollection>();
|
||||
allPropertyTypeCollection = new Dictionary<int, PropertyTypeCollection>();
|
||||
|
||||
foreach (var contentTypeId in contentTypeIds)
|
||||
{
|
||||
//from this we need to make :
|
||||
|
||||
@@ -248,6 +248,22 @@ namespace Umbraco.Tests.Persistence.Repositories
|
||||
}
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void Can_Perform_Get_By_Missing_Guid_On_ContentTypeRepository()
|
||||
{
|
||||
// Arrange
|
||||
var provider = new PetaPocoUnitOfWorkProvider(Logger);
|
||||
var unitOfWork = provider.GetUnitOfWork();
|
||||
using (var repository = CreateRepository(unitOfWork))
|
||||
{
|
||||
// Act
|
||||
var result = repository.Get(Guid.NewGuid());
|
||||
|
||||
// Assert
|
||||
Assert.That(result, Is.Null);
|
||||
}
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void Can_Perform_GetAll_On_ContentTypeRepository()
|
||||
{
|
||||
|
||||
@@ -144,6 +144,19 @@ namespace Umbraco.Tests.Services
|
||||
Assert.AreEqual(11, descendants.Count());
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void Get_With_Missing_Guid()
|
||||
{
|
||||
// Arrange
|
||||
var contentTypeService = ServiceContext.ContentTypeService;
|
||||
|
||||
//Act
|
||||
var result = contentTypeService.GetMediaType(Guid.NewGuid());
|
||||
|
||||
//Assert
|
||||
Assert.IsNull(result);
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void Can_Bulk_Save_New_Hierarchy_Content_Types()
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user