diff --git a/src/Umbraco.Core/Extensions/PublishedContentExtensions.cs b/src/Umbraco.Core/Extensions/PublishedContentExtensions.cs
index 2c110496f03d..4b269a350277 100644
--- a/src/Umbraco.Core/Extensions/PublishedContentExtensions.cs
+++ b/src/Umbraco.Core/Extensions/PublishedContentExtensions.cs
@@ -68,6 +68,7 @@ public static string Name(this IPublishedContent content, IVariationContextAcces
/// The specific culture to get the URL segment for. If null is used the current culture is used
/// (Default is null).
///
+ [Obsolete("Please use GetUrlSegment() on IDocumentUrlService instead. Scheduled for removal in V16.")]
public static string? UrlSegment(this IPublishedContent content, IVariationContextAccessor? variationContextAccessor, string? culture = null)
{
if (content == null)
diff --git a/src/Umbraco.Core/Models/PublishedContent/PublishedContentBase.cs b/src/Umbraco.Core/Models/PublishedContent/PublishedContentBase.cs
index 56f77895788b..bf41498c4320 100644
--- a/src/Umbraco.Core/Models/PublishedContent/PublishedContentBase.cs
+++ b/src/Umbraco.Core/Models/PublishedContent/PublishedContentBase.cs
@@ -31,6 +31,7 @@ public abstract class PublishedContentBase : IPublishedContent
public virtual string Name => this.Name(_variationContextAccessor);
///
+ [Obsolete("Please use GetUrlSegment() on IDocumentUrlService instead. Scheduled for removal in V16.")]
public virtual string? UrlSegment => this.UrlSegment(_variationContextAccessor);
///
@@ -75,7 +76,6 @@ public abstract class PublishedContentBase : IPublishedContent
[Obsolete("Please use TryGetParentKey() on IDocumentNavigationQueryService or IMediaNavigationQueryService instead. Scheduled for removal in V16.")]
public abstract IPublishedContent? Parent { get; }
- // FIXME
///
[Obsolete("Please use TryGetChildrenKeys() on IDocumentNavigationQueryService or IMediaNavigationQueryService instead. Scheduled for removal in V16.")]
public virtual IEnumerable Children => GetChildren();
diff --git a/src/Umbraco.PublishedCache.HybridCache/Factories/CacheNodeFactory.cs b/src/Umbraco.PublishedCache.HybridCache/Factories/CacheNodeFactory.cs
index 7fa38dd62637..e2be9797a0fa 100644
--- a/src/Umbraco.PublishedCache.HybridCache/Factories/CacheNodeFactory.cs
+++ b/src/Umbraco.PublishedCache.HybridCache/Factories/CacheNodeFactory.cs
@@ -1,6 +1,5 @@
-using StackExchange.Profiling.Internal;
-using Umbraco.Cms.Core.Media.EmbedProviders;
-using Umbraco.Cms.Core.Models;
+using Umbraco.Cms.Core.Models;
+using Umbraco.Cms.Core.Services;
using Umbraco.Cms.Core.Strings;
using Umbraco.Extensions;
@@ -10,11 +9,13 @@ internal class CacheNodeFactory : ICacheNodeFactory
{
private readonly IShortStringHelper _shortStringHelper;
private readonly UrlSegmentProviderCollection _urlSegmentProviders;
+ private readonly IDocumentUrlService _documentUrlService;
- public CacheNodeFactory(IShortStringHelper shortStringHelper, UrlSegmentProviderCollection urlSegmentProviders)
+ public CacheNodeFactory(IShortStringHelper shortStringHelper, UrlSegmentProviderCollection urlSegmentProviders, IDocumentUrlService documentUrlService)
{
_shortStringHelper = shortStringHelper;
_urlSegmentProviders = urlSegmentProviders;
+ _documentUrlService = documentUrlService;
}
public ContentCacheNode ToContentCacheNode(IContent content, bool preview)
@@ -126,6 +127,7 @@ private ContentData GetContentData(IContentBase content, bool published, int? te
}
var cultureData = new Dictionary();
+ string? urlSegment = null;
// sanitize - names should be ok but ... never knows
if (content.ContentType.VariesByCulture())
@@ -153,10 +155,14 @@ private ContentData GetContentData(IContentBase content, bool published, int? te
}
}
}
+ else
+ {
+ urlSegment = content.GetUrlSegment(_shortStringHelper, _urlSegmentProviders);
+ }
return new ContentData(
content.Name,
- null,
+ urlSegment,
content.VersionId,
content.UpdateDate,
content.CreatorId,
diff --git a/src/Umbraco.PublishedCache.HybridCache/Persistence/DatabaseCacheRepository.cs b/src/Umbraco.PublishedCache.HybridCache/Persistence/DatabaseCacheRepository.cs
index 63ccf00a2655..df357c90c973 100644
--- a/src/Umbraco.PublishedCache.HybridCache/Persistence/DatabaseCacheRepository.cs
+++ b/src/Umbraco.PublishedCache.HybridCache/Persistence/DatabaseCacheRepository.cs
@@ -596,8 +596,7 @@ private ContentNuDto GetDtoFromContent(IContentBase content, bool published, ICo
cultureData[cultureInfo.Culture] = new CultureVariation
{
Name = cultureInfo.Name,
- UrlSegment =
- content.GetUrlSegment(_shortStringHelper, _urlSegmentProviders, cultureInfo.Culture),
+ UrlSegment = content.GetUrlSegment(_shortStringHelper, _urlSegmentProviders, cultureInfo.Culture),
Date = content.GetUpdateDate(cultureInfo.Culture) ?? DateTime.MinValue,
IsDraft = cultureIsDraft,
};
@@ -865,7 +864,7 @@ private ContentCacheNode CreateContentNodeKit(ContentSourceDto dto, IContentCach
serializer.Deserialize(dto, dto.EditData, dto.EditDataRaw, published);
var draftContentData = new ContentData(
dto.EditName,
- null,
+ deserializedDraftContent?.UrlSegment,
dto.VersionId,
dto.EditVersionDate,
dto.CreatorId,
@@ -904,7 +903,7 @@ private ContentCacheNode CreateContentNodeKit(ContentSourceDto dto, IContentCach
ContentCacheDataModel? deserializedContent = serializer.Deserialize(dto, dto.PubData, dto.PubDataRaw, true);
var publishedContentData = new ContentData(
dto.PubName,
- null,
+ deserializedContent?.UrlSegment,
dto.VersionId,
dto.PubVersionDate,
dto.CreatorId,