diff --git a/src/Umbraco.Infrastructure/Examine/ContentIndexPopulator.cs b/src/Umbraco.Infrastructure/Examine/ContentIndexPopulator.cs index 647429ebc4..24a21d1cb8 100644 --- a/src/Umbraco.Infrastructure/Examine/ContentIndexPopulator.cs +++ b/src/Umbraco.Infrastructure/Examine/ContentIndexPopulator.cs @@ -99,15 +99,12 @@ public class ContentIndexPopulator : IndexPopulator { content = _contentService.GetPagedDescendants(contentParentId, pageIndex, pageSize, out _).ToArray(); - if (content.Length > 0) - { - var valueSets = _contentValueSetBuilder.GetValueSets(content).ToList(); + var valueSets = _contentValueSetBuilder.GetValueSets(content).ToList(); - // ReSharper disable once PossibleMultipleEnumeration - foreach (IIndex index in indexes) - { - index.IndexItems(valueSets); - } + // ReSharper disable once PossibleMultipleEnumeration + foreach (IIndex index in indexes) + { + index.IndexItems(valueSets); } pageIndex++; @@ -127,35 +124,32 @@ public class ContentIndexPopulator : IndexPopulator // note: We will filter for published variants in the validator content = _contentService.GetPagedDescendants(contentParentId, pageIndex, pageSize, out _, PublishedQuery, Ordering.By("Path")).ToArray(); - if (content.Length > 0) + var indexableContent = new List(); + + foreach (IContent item in content) { - var indexableContent = new List(); - - foreach (IContent item in content) + if (item.Level == 1) { - if (item.Level == 1) + // first level pages are always published so no need to filter them + indexableContent.Add(item); + publishedPages.Add(item.Id); + } + else + { + if (publishedPages.Contains(item.ParentId)) { - // first level pages are always published so no need to filter them - indexableContent.Add(item); + // only index when parent is published publishedPages.Add(item.Id); - } - else - { - if (publishedPages.Contains(item.ParentId)) - { - // only index when parent is published - publishedPages.Add(item.Id); - indexableContent.Add(item); - } + indexableContent.Add(item); } } + } - var valueSets = _contentValueSetBuilder.GetValueSets(indexableContent.ToArray()).ToList(); + var valueSets = _contentValueSetBuilder.GetValueSets(indexableContent.ToArray()).ToList(); - foreach (IIndex index in indexes) - { - index.IndexItems(valueSets); - } + foreach (IIndex index in indexes) + { + index.IndexItems(valueSets); } pageIndex++; diff --git a/src/Umbraco.Infrastructure/Examine/MediaIndexPopulator.cs b/src/Umbraco.Infrastructure/Examine/MediaIndexPopulator.cs index 19a2a96160..20df2c229e 100644 --- a/src/Umbraco.Infrastructure/Examine/MediaIndexPopulator.cs +++ b/src/Umbraco.Infrastructure/Examine/MediaIndexPopulator.cs @@ -59,13 +59,10 @@ public class MediaIndexPopulator : IndexPopulator { media = _mediaService.GetPagedDescendants(mediaParentId, pageIndex, pageSize, out _).ToArray(); - if (media.Length > 0) + // ReSharper disable once PossibleMultipleEnumeration + foreach (IIndex index in indexes) { - // ReSharper disable once PossibleMultipleEnumeration - foreach (IIndex index in indexes) - { - index.IndexItems(_mediaValueSetBuilder.GetValueSets(media)); - } + index.IndexItems(_mediaValueSetBuilder.GetValueSets(media)); } pageIndex++; diff --git a/src/Umbraco.Infrastructure/Examine/MemberIndexPopulator.cs b/src/Umbraco.Infrastructure/Examine/MemberIndexPopulator.cs index 9dc2102d5e..29f0763e28 100644 --- a/src/Umbraco.Infrastructure/Examine/MemberIndexPopulator.cs +++ b/src/Umbraco.Infrastructure/Examine/MemberIndexPopulator.cs @@ -32,13 +32,10 @@ public class MemberIndexPopulator : IndexPopulator { members = _memberService.GetAll(pageIndex, pageSize, out _).ToArray(); - if (members.Length > 0) + // ReSharper disable once PossibleMultipleEnumeration + foreach (IIndex index in indexes) { - // ReSharper disable once PossibleMultipleEnumeration - foreach (IIndex index in indexes) - { - index.IndexItems(_valueSetBuilder.GetValueSets(members)); - } + index.IndexItems(_valueSetBuilder.GetValueSets(members)); } pageIndex++;