Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

V15: Add back url segments again #17390

Merged
merged 3 commits into from
Oct 29, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions src/Umbraco.Core/Extensions/PublishedContentExtensions.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// Copyright (c) Umbraco.

Check notice on line 1 in src/Umbraco.Core/Extensions/PublishedContentExtensions.cs

View check run for this annotation

CodeScene Delta Analysis / CodeScene Cloud Delta Analysis (release/15.0)

ℹ Getting worse: Lines of Code in a Single File

The lines of code increases from 1344 to 1345, improve code health by reducing it to 1000. The number of Lines of Code in a single file. More Lines of Code lowers the code health.
// See LICENSE for more details.

using System.Data;
Expand Down Expand Up @@ -68,6 +68,7 @@
/// The specific culture to get the URL segment for. If null is used the current culture is used
/// (Default is null).
/// </param>
[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)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@ public abstract class PublishedContentBase : IPublishedContent
public virtual string Name => this.Name(_variationContextAccessor);

/// <inheritdoc />
[Obsolete("Please use GetUrlSegment() on IDocumentUrlService instead. Scheduled for removal in V16.")]
public virtual string? UrlSegment => this.UrlSegment(_variationContextAccessor);

/// <inheritdoc />
Expand Down Expand Up @@ -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
/// <inheritdoc />
[Obsolete("Please use TryGetChildrenKeys() on IDocumentNavigationQueryService or IMediaNavigationQueryService instead. Scheduled for removal in V16.")]
public virtual IEnumerable<IPublishedContent> Children => GetChildren();
Expand Down
Original file line number Diff line number Diff line change
@@ -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;

Expand All @@ -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)
Expand Down Expand Up @@ -126,6 +127,7 @@ private ContentData GetContentData(IContentBase content, bool published, int? te
}

var cultureData = new Dictionary<string, CultureVariation>();
string? urlSegment = null;

// sanitize - names should be ok but ... never knows
if (content.ContentType.VariesByCulture())
Expand Down Expand Up @@ -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,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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,
};
Expand Down Expand Up @@ -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,
Expand Down Expand Up @@ -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,
Expand Down
Loading