Querying: Restore ability to retrieve all children published in any culture (closes #20760) (#20766)

* Restore ability to retrieve all children published in any culture.

* Fixed typo in test name.
This commit is contained in:
Andy Butland
2025-11-10 03:02:10 +01:00
committed by GitHub
parent 04918ec3d2
commit fcfaff9daa
3 changed files with 62 additions and 23 deletions

View File

@@ -69,7 +69,9 @@ public class PublishStatusService : IPublishStatusManagementService, IPublishSta
if (_publishedCultures.TryGetValue(documentKey, out ISet<string>? publishedCultures))
{
return publishedCultures.Contains(culture, StringComparer.InvariantCultureIgnoreCase);
// If "*" is provided as the culture, we consider this as "published in any culture". This aligns
// with behaviour in Umbraco 13.
return culture == Constants.System.InvariantCulture || publishedCultures.Contains(culture, StringComparer.InvariantCultureIgnoreCase);
}
_logger.LogDebug("Document {DocumentKey} not found in the publish status cache", documentKey);

View File

@@ -1,4 +1,4 @@
using Umbraco.Cms.Core.Models.PublishedContent;
using Umbraco.Cms.Core.Models.PublishedContent;
using Umbraco.Cms.Core.PublishedCache;
using Umbraco.Extensions;
@@ -40,13 +40,14 @@ internal sealed class PublishedContentStatusFilteringService : IPublishedContent
_publishStatusQueryService.IsDocumentPublished(key, culture)
&& _publishStatusQueryService.HasPublishedAncestorPath(key));
return WhereIsInvariantOrHasCulture(candidateKeys, culture, preview).ToArray();
return WhereIsInvariantOrHasCultureOrRequestedAllCultures(candidateKeys, culture, preview).ToArray();
}
private IEnumerable<IPublishedContent> WhereIsInvariantOrHasCulture(IEnumerable<Guid> keys, string culture, bool preview)
private IEnumerable<IPublishedContent> WhereIsInvariantOrHasCultureOrRequestedAllCultures(IEnumerable<Guid> keys, string culture, bool preview)
=> keys
.Select(key => _publishedContentCache.GetById(preview, key))
.WhereNotNull()
.Where(content => content.ContentType.VariesByCulture() is false
.Where(content => culture == Constants.System.InvariantCulture
|| content.ContentType.VariesByCulture() is false
|| content.Cultures.ContainsKey(culture));
}