From 2c3a2e2b2da9fd03cc0a1473961157fa5b082bba Mon Sep 17 00:00:00 2001 From: Andy Butland Date: Mon, 22 Sep 2025 11:26:25 +0200 Subject: [PATCH] Cherry-pick of #20129 to 16. --- src/Umbraco.Infrastructure/IPublishedContentQuery.cs | 2 ++ src/Umbraco.Infrastructure/PublishedContentQuery.cs | 7 +++++-- .../Extensions/FriendlyPublishedContentExtensions.cs | 4 ++-- 3 files changed, 9 insertions(+), 4 deletions(-) diff --git a/src/Umbraco.Infrastructure/IPublishedContentQuery.cs b/src/Umbraco.Infrastructure/IPublishedContentQuery.cs index 9a5da442c1..0b2eac8752 100644 --- a/src/Umbraco.Infrastructure/IPublishedContentQuery.cs +++ b/src/Umbraco.Infrastructure/IPublishedContentQuery.cs @@ -24,6 +24,8 @@ public interface IPublishedContentQuery IEnumerable ContentAtRoot(); + IEnumerable ContentAtRoot(string? culture) => culture is null ? ContentAtRoot() : throw new NotSupportedException(); + IPublishedContent? Media(int id); IPublishedContent? Media(Guid id); diff --git a/src/Umbraco.Infrastructure/PublishedContentQuery.cs b/src/Umbraco.Infrastructure/PublishedContentQuery.cs index 221a7545ba..0d8b230114 100644 --- a/src/Umbraco.Infrastructure/PublishedContentQuery.cs +++ b/src/Umbraco.Infrastructure/PublishedContentQuery.cs @@ -144,6 +144,9 @@ public class PublishedContentQuery : IPublishedContentQuery public IEnumerable ContentAtRoot() => ItemsAtRoot(_publishedContent); + public IEnumerable ContentAtRoot(string? culture) + => ItemsAtRoot(_publishedContent, culture); + #endregion #region Media @@ -212,8 +215,8 @@ public class PublishedContentQuery : IPublishedContentQuery private IEnumerable ItemsByIds(IPublishedCache? cache, IEnumerable ids) => ids.Select(eachId => ItemById(eachId, cache)).WhereNotNull(); - private static IEnumerable ItemsAtRoot(IPublishedCache? cache) - => cache?.GetAtRoot() ?? Array.Empty(); + private static IEnumerable ItemsAtRoot(IPublishedCache? cache, string? culture = null) + => cache?.GetAtRoot(culture) ?? Array.Empty(); #endregion diff --git a/src/Umbraco.Web.Common/Extensions/FriendlyPublishedContentExtensions.cs b/src/Umbraco.Web.Common/Extensions/FriendlyPublishedContentExtensions.cs index 921c815e2f..15c0a7bd6f 100644 --- a/src/Umbraco.Web.Common/Extensions/FriendlyPublishedContentExtensions.cs +++ b/src/Umbraco.Web.Common/Extensions/FriendlyPublishedContentExtensions.cs @@ -347,7 +347,7 @@ public static class FriendlyPublishedContentExtensions /// /// /// - /// This can be useful in order to return all nodes in an entire site by a type when combined with TypedContentAtRoot + /// This can be useful in order to return all nodes in an entire site by a type when combined with ContentAtRoot. /// public static IEnumerable DescendantsOrSelfOfType( this IEnumerable parentNodes, string docTypeAlias, string? culture = null) @@ -375,7 +375,7 @@ public static class FriendlyPublishedContentExtensions /// /// /// - /// This can be useful in order to return all nodes in an entire site by a type when combined with TypedContentAtRoot + /// This can be useful in order to return all nodes in an entire site by a type when combined with ContentAtRoot. /// public static IEnumerable DescendantsOrSelf( this IEnumerable parentNodes,