Compare commits

..

10 Commits

Author SHA1 Message Date
Shannon b8ea50d644 Merge remote-tracking branch 'origin/6.2.4' into 7.1.8
Conflicts:
	build/NuSpecs/build/UmbracoCms.targets
	src/Umbraco.Core/Configuration/UmbracoVersion.cs
	src/Umbraco.Core/Persistence/Factories/UmbracoEntityFactory.cs
	src/Umbraco.Core/Persistence/Repositories/EntityRepository.cs
	src/Umbraco.Tests/Services/EntityServiceTests.cs
	src/Umbraco.Web.UI/Umbraco.Web.UI.csproj
2014-10-08 17:30:45 +11:00
Shannon 1eab26c0f6 reverts IQuery 2014-10-08 17:26:55 +11:00
Shannon 0543c620eb bumps version 2014-10-08 17:25:06 +11:00
Shannon 646e5f173d Fixes descendant queries to ensure that the comma is suffixed to the path, otherwise strange things could happen when there are longer ids! 2014-10-08 17:23:14 +11:00
Shannon b5594517bd Fixes: U4-5583 Can no longer link to Media Items from RTE in 6.2.3 - Due to a cherry pick/merge issue since the newer 7.x EntityRepository deals with NVarchar and NText values whereas the 6.x one did not. Have backported the mapping poco classes to now also support NVarchar and NText for the EntityRepository. Have also fixed the basic query to ensure that there are no left joins before inner joins which can also cause problems. Fixed up the duplicate where clause. Adds more tests to entity service. 2014-10-08 17:13:28 +11:00
Sebastiaan Janssen 5501c9531b Bump version 2014-10-07 11:22:51 +02:00
Shannon 8824ab2b27 reverts JS from tree controller and updates the c# method to create the tree child node URLs to ensure the custom start node param is ignored, this is a bit cleaner. 2014-10-07 12:52:02 +11:00
Shannon b60e292d5f Fixes: U4-5578 MNTP with root node, recursive output 2014-10-07 11:51:11 +11:00
Shannon e1dcf6b061 reverts IQuery 2014-10-07 11:50:35 +11:00
Sebastiaan Janssen 246dfba8ac Bump version 2014-10-02 18:06:15 +02:00
11 changed files with 86 additions and 44 deletions
+1 -1
View File
@@ -1 +1 @@
7.1.7
7.1.8
@@ -5,7 +5,7 @@ namespace Umbraco.Core.Configuration
{
public class UmbracoVersion
{
private static readonly Version Version = new Version("7.1.7");
private static readonly Version Version = new Version("7.1.8");
/// <summary>
/// Gets the current version of Umbraco.
@@ -4,6 +4,28 @@ using System.Linq.Expressions;
namespace Umbraco.Core.Persistence.Querying
{
/// <summary>
/// SD: This is a horrible hack but unless we break compatibility with anyone who's actually implemented IQuery{T} there's not much we can do.
/// The IQuery{T} interface is useless without having a GetWhereClauses method and cannot be used for tests.
/// We have to wait till v8 to make this change I suppose.
/// </summary>
internal static class QueryExtensions
{
/// <summary>
/// Returns all translated where clauses and their sql parameters
/// </summary>
/// <returns></returns>
public static IEnumerable<Tuple<string, object[]>> GetWhereClauses<T>(this IQuery<T> query)
{
var q = query as Query<T>;
if (q == null)
{
throw new NotSupportedException(typeof(IQuery<T>) + " cannot be cast to " + typeof(Query<T>));
}
return q.GetWhereClauses();
}
}
/// <summary>
/// Represents a query for building Linq translatable SQL queries
/// </summary>
@@ -17,10 +39,6 @@ namespace Umbraco.Core.Persistence.Querying
/// <returns>This instance so calls to this method are chainable</returns>
IQuery<T> Where(Expression<Func<T, bool>> predicate);
/// <summary>
/// Returns all translated where clauses and their sql parameters
/// </summary>
/// <returns></returns>
IEnumerable<Tuple<string, object[]>> GetWhereClauses();
}
}
@@ -193,18 +193,7 @@ namespace Umbraco.Core.Persistence.Repositories
public virtual IEnumerable<IUmbracoEntity> GetByQuery(IQuery<IUmbracoEntity> query)
{
//TODO: We need to fix all of this and how it handles parameters!
var wheres = query.GetWhereClauses().ToArray();
var sqlClause = GetBase(false, false, sql1 =>
{
//adds the additional filters
foreach (var whereClause in wheres)
{
sql1.Where(whereClause.Item1, whereClause.Item2);
}
});
var sqlClause = GetBase(false, false, null);
var translator = new SqlTranslator<IUmbracoEntity>(sqlClause, query);
var sql = translator.Translate().Append(GetGroupBy(false, false));
@@ -222,17 +211,7 @@ namespace Umbraco.Core.Persistence.Repositories
bool isContent = objectTypeId == new Guid(Constants.ObjectTypes.Document);
bool isMedia = objectTypeId == new Guid(Constants.ObjectTypes.Media);
var wheres = query.GetWhereClauses().ToArray();
var sqlClause = GetBaseWhere(GetBase, isContent, isMedia, sql1 =>
{
//adds the additional filters
foreach (var whereClause in wheres)
{
sql1.Where(whereClause.Item1, whereClause.Item2);
}
}, objectTypeId);
var sqlClause = GetBaseWhere(GetBase, isContent, isMedia, null, objectTypeId);
var translator = new SqlTranslator<IUmbracoEntity>(sqlClause, query);
var entitySql = translator.Translate();
@@ -241,6 +220,8 @@ namespace Umbraco.Core.Persistence.Repositories
if (isMedia)
{
var wheres = query.GetWhereClauses().ToArray();
var mediaSql = GetFullSqlForMedia(entitySql.Append(GetGroupBy(isContent, true, false)), sql =>
{
//adds the additional filters
@@ -259,7 +240,8 @@ namespace Umbraco.Core.Persistence.Repositories
else
{
//use dynamic so that we can get ALL properties from the SQL so we can chuck that data into our AdditionalData
var dtos = _work.Database.Fetch<dynamic>(entitySql.Append(GetGroupBy(isContent, false)));
var finalSql = entitySql.Append(GetGroupBy(isContent, false));
var dtos = _work.Database.Fetch<dynamic>(finalSql);
return dtos.Select(factory.BuildEntityFromDynamic).Cast<IUmbracoEntity>().ToList();
}
}
@@ -362,10 +344,8 @@ namespace Umbraco.Core.Persistence.Repositories
var entitySql = new Sql()
.Select(columns.ToArray())
.From("umbracoNode umbracoNode")
.LeftJoin("umbracoNode parent").On("parent.parentID = umbracoNode.id");
.From("umbracoNode umbracoNode");
if (isContent || isMedia)
{
entitySql.InnerJoin("cmsContent content").On("content.nodeId = umbracoNode.id")
@@ -378,6 +358,8 @@ namespace Umbraco.Core.Persistence.Repositories
.On("umbracoNode.id = latest.nodeId");
}
entitySql.LeftJoin("umbracoNode parent").On("parent.parentID = umbracoNode.id");
if (customFilter != null)
{
customFilter(entitySql);
+2 -1
View File
@@ -536,7 +536,8 @@ namespace Umbraco.Core.Services
{
using (var repository = _repositoryFactory.CreateContentRepository(_uowProvider.GetUnitOfWork()))
{
var query = Query<IContent>.Builder.Where(x => x.Path.StartsWith(content.Path) && x.Id != content.Id);
var pathMatch = content.Path + ",";
var query = Query<IContent>.Builder.Where(x => x.Path.StartsWith(pathMatch) && x.Id != content.Id);
var contents = repository.GetByQuery(query);
return contents;
+2 -1
View File
@@ -252,7 +252,8 @@ namespace Umbraco.Core.Services
using (var repository = _repositoryFactory.CreateEntityRepository(_uowProvider.GetUnitOfWork()))
{
var entity = repository.Get(id);
var query = Query<IUmbracoEntity>.Builder.Where(x => x.Path.StartsWith(entity.Path) && x.Id != id);
var pathMatch = entity.Path + ",";
var query = Query<IUmbracoEntity>.Builder.Where(x => x.Path.StartsWith(pathMatch) && x.Id != id);
var entities = repository.GetByQuery(query);
return entities;
+2 -1
View File
@@ -419,7 +419,8 @@ namespace Umbraco.Core.Services
var uow = _uowProvider.GetUnitOfWork();
using (var repository = _repositoryFactory.CreateMediaRepository(uow))
{
var query = Query<IMedia>.Builder.Where(x => x.Path.StartsWith(media.Path) && x.Id != media.Id);
var pathMatch = media.Path + ",";
var query = Query<IMedia>.Builder.Where(x => x.Path.StartsWith(pathMatch) && x.Id != media.Id);
var medias = repository.GetByQuery(query);
return medias;
@@ -76,6 +76,30 @@ namespace Umbraco.Tests.Services
Assert.That(entities.Any(x => x.Trashed), Is.False);
}
[Test]
public void EntityService_Can_Get_Children_By_ParentId()
{
var service = ServiceContext.EntityService;
var entities = service.GetChildren(folderId);
Assert.That(entities.Any(), Is.True);
Assert.That(entities.Count(), Is.EqualTo(3));
Assert.That(entities.Any(x => x.Trashed), Is.False);
}
[Test]
public void EntityService_Can_Get_Descendants_By_ParentId()
{
var service = ServiceContext.EntityService;
var entities = service.GetDescendents(folderId);
Assert.That(entities.Any(), Is.True);
Assert.That(entities.Count(), Is.EqualTo(4));
Assert.That(entities.Any(x => x.Trashed), Is.False);
}
[Test]
public void EntityService_Throws_When_Getting_All_With_Invalid_Type()
{
@@ -129,7 +153,7 @@ namespace Umbraco.Tests.Services
var entities = service.GetAll(UmbracoObjectTypes.Media).ToArray();
Assert.That(entities.Any(), Is.True);
Assert.That(entities.Count(), Is.EqualTo(3));
Assert.That(entities.Count(), Is.EqualTo(5));
Assert.That(
entities.Any(
@@ -150,6 +174,8 @@ namespace Umbraco.Tests.Services
private static bool _isSetup = false;
private int folderId;
public override void CreateTestData()
{
if (_isSetup == false)
@@ -160,8 +186,9 @@ namespace Umbraco.Tests.Services
//Create and Save folder-Media -> 1050
var folderMediaType = ServiceContext.ContentTypeService.GetMediaType(1031);
var folder = MockedMedia.CreateMediaFolder(folderMediaType, -1);
var folder = MockedMedia.CreateMediaFolder(folderMediaType, -1);
ServiceContext.MediaService.Save(folder, 0);
folderId = folder.Id;
//Create and Save image-Media -> 1051
var imageMediaType = ServiceContext.ContentTypeService.GetMediaType(1032);
@@ -172,6 +199,12 @@ namespace Umbraco.Tests.Services
var fileMediaType = ServiceContext.ContentTypeService.GetMediaType(1033);
var file = MockedMedia.CreateMediaFile(fileMediaType, folder.Id);
ServiceContext.MediaService.Save(file, 0);
var subfolder = MockedMedia.CreateMediaFolder(folderMediaType, folder.Id);
ServiceContext.MediaService.Save(subfolder, 0);
var subfolder2 = MockedMedia.CreateMediaFolder(folderMediaType, subfolder.Id);
ServiceContext.MediaService.Save(subfolder2, 0);
}
}
@@ -1,4 +1,7 @@
//used for the media picker dialog
//TODO: SD: Pretty sure we don't want this anymore and we should just be using the treepicker.html instead for all tree picking.
//used for the content picker dialog
angular.module("umbraco").controller("Umbraco.Dialogs.ContentPickerController",
function ($scope, eventsService, entityResource, searchService, $log) {
var dialogOptions = $scope.dialogOptions;
+2 -2
View File
@@ -2530,9 +2530,9 @@ xcopy "$(ProjectDir)"..\packages\SqlServerCE.4.0.0.0\x86\*.* "$(TargetDir)x86\"
<WebProjectProperties>
<UseIIS>True</UseIIS>
<AutoAssignPort>True</AutoAssignPort>
<DevelopmentServerPort>7170</DevelopmentServerPort>
<DevelopmentServerPort>7180</DevelopmentServerPort>
<DevelopmentServerVPath>/</DevelopmentServerVPath>
<IISUrl>http://localhost:7170</IISUrl>
<IISUrl>http://localhost:7180</IISUrl>
<NTLMAuthentication>False</NTLMAuthentication>
<UseCustomServer>False</UseCustomServer>
<CustomServerUrl>
+4 -1
View File
@@ -13,7 +13,10 @@ namespace Umbraco.Web.Trees
.EnsureEndsWith('?');
//now we need to append the query strings
actionUrl += "id=" + nodeId.EnsureEndsWith('&') + queryStrings.ToQueryString("id");
actionUrl += "id=" + nodeId.EnsureEndsWith('&') + queryStrings.ToQueryString("id",
//Always ignore the custom start node id when generating URLs for tree nodes since this is a custom once-only parameter
// that should only ever be used when requesting a tree to render (root), not a tree node
TreeQueryStringParameters.StartNodeId);
return actionUrl;
}