From 0454c54d1c41d7a129643f2c50e531b5bbaf39c6 Mon Sep 17 00:00:00 2001 From: Per Ploug Date: Wed, 21 Oct 2015 09:49:45 +0200 Subject: [PATCH] Fixed: Given -1 MediaService returns all descendant media It returned the entire media tree given the ID -1, changing this so it returns children below root instead --- src/Umbraco.Core/Services/MediaService.cs | 15 ++++----------- 1 file changed, 4 insertions(+), 11 deletions(-) diff --git a/src/Umbraco.Core/Services/MediaService.cs b/src/Umbraco.Core/Services/MediaService.cs index 990b0a84d5..3bc97c60bc 100644 --- a/src/Umbraco.Core/Services/MediaService.cs +++ b/src/Umbraco.Core/Services/MediaService.cs @@ -394,12 +394,8 @@ namespace Umbraco.Core.Services using (var repository = RepositoryFactory.CreateMediaRepository(UowProvider.GetUnitOfWork())) { var query = Query.Builder; - //if the id is -1, then just get all - if (id != -1) - { - query.Where(x => x.ParentId == id); - } - + query.Where(x => x.ParentId == id); + long total; var medias = repository.GetPagedResultsByQuery(query, pageIndex, pageSize, out total, orderBy, orderDirection, filter); @@ -427,11 +423,8 @@ namespace Umbraco.Core.Services using (var repository = RepositoryFactory.CreateMediaRepository(UowProvider.GetUnitOfWork())) { var query = Query.Builder; - //if the id is -1, then just get all - if (id != -1) - { - query.Where(x => x.ParentId == id); - } + query.Where(x => x.ParentId == id); + var medias = repository.GetPagedResultsByQuery(query, pageIndex, pageSize, out totalChildren, orderBy, orderDirection, filter); return medias;