Skip to content

Commit 646e5f1

Browse files
committed
Fixes descendant queries to ensure that the comma is suffixed to the path, otherwise strange things could happen when there are longer ids!
1 parent b559451 commit 646e5f1

File tree

3 files changed

+6
-3
lines changed

3 files changed

+6
-3
lines changed

src/Umbraco.Core/Services/ContentService.cs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -500,7 +500,8 @@ public IEnumerable<IContent> GetDescendants(IContent content)
500500
{
501501
using (var repository = _repositoryFactory.CreateContentRepository(_uowProvider.GetUnitOfWork()))
502502
{
503-
var query = Query<IContent>.Builder.Where(x => x.Path.StartsWith(content.Path) && x.Id != content.Id);
503+
var pathMatch = content.Path + ",";
504+
var query = Query<IContent>.Builder.Where(x => x.Path.StartsWith(pathMatch) && x.Id != content.Id);
504505
var contents = repository.GetByQuery(query);
505506

506507
return contents;

src/Umbraco.Core/Services/EntityService.cs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -252,7 +252,8 @@ public virtual IEnumerable<IUmbracoEntity> GetDescendents(int id)
252252
using (var repository = _repositoryFactory.CreateEntityRepository(_uowProvider.GetUnitOfWork()))
253253
{
254254
var entity = repository.Get(id);
255-
var query = Query<IUmbracoEntity>.Builder.Where(x => x.Path.StartsWith(entity.Path) && x.Id != id);
255+
var pathMatch = entity.Path + ",";
256+
var query = Query<IUmbracoEntity>.Builder.Where(x => x.Path.StartsWith(pathMatch) && x.Id != id);
256257
var entities = repository.GetByQuery(query);
257258

258259
return entities;

src/Umbraco.Core/Services/MediaService.cs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -419,7 +419,8 @@ public IEnumerable<IMedia> GetDescendants(IMedia media)
419419
var uow = _uowProvider.GetUnitOfWork();
420420
using (var repository = _repositoryFactory.CreateMediaRepository(uow))
421421
{
422-
var query = Query<IMedia>.Builder.Where(x => x.Path.StartsWith(media.Path) && x.Id != media.Id);
422+
var pathMatch = media.Path + ",";
423+
var query = Query<IMedia>.Builder.Where(x => x.Path.StartsWith(pathMatch) && x.Id != media.Id);
423424
var medias = repository.GetByQuery(query);
424425

425426
return medias;

0 commit comments

Comments
 (0)