Skip to content

Commit 2a6bb64

Browse files
NillasKAZeegaan
andauthored
V17 - Properties and validators, removing obsoleted code (#19961)
* Removing obsoleted code from ApiMediaQueryService.cs * Removing obsoleted code from ApiRichTextMarkupParserTests.cs * Removing obsoleted code from ContentCacheRefresher.cs * Removing obsoleted code from ContentFinderByUrlAlias.cs and adjusting its tests to use the new logic * Removing obsoleted code from ContentFinderByUrl.cs & its dependencies * Removing obsoleted code from ApiRichTextMarkupParserTests.cs * Removing obsoleted code from DocumentCache.cs & its dependencies * Removing obsoleted code from MediaCache.cs & its dependencies * Removing obsoleted code from PublishedCacheBase.cs & its dependencies * Removing obsoleted code from RenderNoContentController.cs and its tests * Removing obsoleted code from UmbracoRouteValueTransformer.cs * Removing obsoleted constructors from DefaultUrlProvider.cs * Removing the RadioValueEditor.cs & RadioValueValidator.cs obsoleted classes. * Removing obsolete constructor from MultipleValueValidator.cs * Removing obsolete constructor from EmailValidator.cs * Removing obsoleted code from DataValueReferenceFactoryCollection.cs * Removing obsoleted code from ApiContentBuilderBase.cs * Fixing constructor missing attribute * Making use of the TryGet result * Fixing use of obsoleted constructor * Removing silly bookmark comment * Fixing deleted code and restructuring to use new cache * Making use of TryGetRootKeys bool, to return null if false. * Extending code to use new constructor * Updated PublishedContentQuery.cs to return empty array Co-authored-by: Nikolaj Geisle <[email protected]> --------- Co-authored-by: Nikolaj Geisle <[email protected]>
1 parent 156bcdc commit 2a6bb64

File tree

30 files changed

+177
-595
lines changed

30 files changed

+177
-595
lines changed

src/Umbraco.Cms.Api.Delivery/Services/ApiMediaQueryService.cs

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -66,7 +66,12 @@ private IPublishedMediaCache GetRequiredPublishedMediaCache()
6666
private IPublishedContent? TryGetByPath(string path, IPublishedMediaCache mediaCache)
6767
{
6868
var segments = path.Split(Constants.CharArrays.ForwardSlash, StringSplitOptions.RemoveEmptyEntries);
69-
IEnumerable<IPublishedContent> currentChildren = mediaCache.GetAtRoot();
69+
if (_mediaNavigationQueryService.TryGetRootKeys(out IEnumerable<Guid> rootKeys) is false)
70+
{
71+
return null;
72+
}
73+
74+
IEnumerable<IPublishedContent> currentChildren = rootKeys.Select(x => mediaCache.GetById(false, x)).WhereNotNull();
7075
IPublishedContent? resolvedMedia = null;
7176

7277
foreach (var segment in segments)
@@ -101,9 +106,9 @@ private IPublishedMediaCache GetRequiredPublishedMediaCache()
101106
}
102107

103108
IPublishedMediaCache mediaCache = GetRequiredPublishedMediaCache();
104-
if (childrenOf.Trim(Constants.CharArrays.ForwardSlash).Length == 0)
109+
if (childrenOf.Trim(Constants.CharArrays.ForwardSlash).Length == 0 && _mediaNavigationQueryService.TryGetRootKeys(out IEnumerable<Guid> rootKeys))
105110
{
106-
return mediaCache.GetAtRoot();
111+
return rootKeys.Select(x => mediaCache.GetById(false, x)).WhereNotNull();
107112
}
108113

109114
IPublishedContent? parent = Guid.TryParse(childrenOf, out Guid parentKey)

src/Umbraco.Core/Cache/Refreshers/Implement/ContentCacheRefresher.cs

Lines changed: 0 additions & 33 deletions
Original file line numberDiff line numberDiff line change
@@ -27,39 +27,6 @@ public sealed class ContentCacheRefresher : PayloadCacheRefresherBase<ContentCac
2727
private readonly IPublishStatusManagementService _publishStatusManagementService;
2828
private readonly IIdKeyMap _idKeyMap;
2929

30-
[Obsolete("Use the constructor with ICacheManager instead, scheduled for removal in V17.")]
31-
public ContentCacheRefresher(
32-
AppCaches appCaches,
33-
IJsonSerializer serializer,
34-
IIdKeyMap idKeyMap,
35-
IDomainService domainService,
36-
IEventAggregator eventAggregator,
37-
ICacheRefresherNotificationFactory factory,
38-
IDocumentUrlService documentUrlService,
39-
IDomainCacheService domainCacheService,
40-
IDocumentNavigationQueryService documentNavigationQueryService,
41-
IDocumentNavigationManagementService documentNavigationManagementService,
42-
IContentService contentService,
43-
IPublishStatusManagementService publishStatusManagementService,
44-
IDocumentCacheService documentCacheService)
45-
: this(
46-
appCaches,
47-
serializer,
48-
idKeyMap,
49-
domainService,
50-
eventAggregator,
51-
factory,
52-
documentUrlService,
53-
domainCacheService,
54-
documentNavigationQueryService,
55-
documentNavigationManagementService,
56-
contentService,
57-
publishStatusManagementService,
58-
documentCacheService,
59-
StaticServiceProvider.Instance.GetRequiredService<ICacheManager>())
60-
{
61-
}
62-
6330
public ContentCacheRefresher(
6431
AppCaches appCaches,
6532
IJsonSerializer serializer,

src/Umbraco.Core/Cache/Refreshers/Implement/MediaCacheRefresher.cs

Lines changed: 0 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -22,31 +22,6 @@ public sealed class MediaCacheRefresher : PayloadCacheRefresherBase<MediaCacheRe
2222
private readonly IMediaCacheService _mediaCacheService;
2323
private readonly ICacheManager _cacheManager;
2424

25-
[Obsolete("Use the constructor with ICacheManager instead, scheduled for removal in V17.")]
26-
public MediaCacheRefresher(
27-
AppCaches appCaches,
28-
IJsonSerializer serializer,
29-
IIdKeyMap idKeyMap,
30-
IEventAggregator eventAggregator,
31-
ICacheRefresherNotificationFactory factory,
32-
IMediaNavigationQueryService mediaNavigationQueryService,
33-
IMediaNavigationManagementService mediaNavigationManagementService,
34-
IMediaService mediaService,
35-
IMediaCacheService mediaCacheService)
36-
: this(
37-
appCaches,
38-
serializer,
39-
idKeyMap,
40-
eventAggregator,
41-
factory,
42-
mediaNavigationQueryService,
43-
mediaNavigationManagementService,
44-
mediaService,
45-
mediaCacheService,
46-
StaticServiceProvider.Instance.GetRequiredService<ICacheManager>())
47-
{
48-
}
49-
5025
public MediaCacheRefresher(
5126
AppCaches appCaches,
5227
IJsonSerializer serializer,

src/Umbraco.Core/DeliveryApi/ApiContentBuilderBase.cs

Lines changed: 1 addition & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,4 @@
1-
using Microsoft.Extensions.DependencyInjection;
2-
using Umbraco.Cms.Core.DependencyInjection;
3-
using Umbraco.Cms.Core.Models.DeliveryApi;
1+
using Umbraco.Cms.Core.Models.DeliveryApi;
42
using Umbraco.Cms.Core.Models.PublishedContent;
53
using Umbraco.Extensions;
64

@@ -12,19 +10,6 @@ public abstract class ApiContentBuilderBase<T>
1210
private readonly IApiContentNameProvider _apiContentNameProvider;
1311
private readonly IOutputExpansionStrategyAccessor _outputExpansionStrategyAccessor;
1412

15-
[Obsolete("Please use the constructor that takes all parameters. Scheduled for removal in Umbraco 17.")]
16-
protected ApiContentBuilderBase(
17-
IApiContentNameProvider apiContentNameProvider,
18-
IApiContentRouteBuilder apiContentRouteBuilder,
19-
IOutputExpansionStrategyAccessor outputExpansionStrategyAccessor)
20-
: this(
21-
apiContentNameProvider,
22-
apiContentRouteBuilder,
23-
outputExpansionStrategyAccessor,
24-
StaticServiceProvider.Instance.GetRequiredService<IVariationContextAccessor>())
25-
{
26-
}
27-
2813
protected ApiContentBuilderBase(
2914
IApiContentNameProvider apiContentNameProvider,
3015
IApiContentRouteBuilder apiContentRouteBuilder,

src/Umbraco.Core/PropertyEditors/DataValueReferenceFactoryCollection.cs

Lines changed: 0 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,5 @@
1-
using Microsoft.Extensions.DependencyInjection;
21
using Microsoft.Extensions.Logging;
32
using Umbraco.Cms.Core.Composing;
4-
using Umbraco.Cms.Core.DependencyInjection;
53
using Umbraco.Cms.Core.Models;
64
using Umbraco.Cms.Core.Models.Editors;
75

@@ -17,17 +15,6 @@ public class DataValueReferenceFactoryCollection : BuilderCollectionBase<IDataVa
1715

1816
private readonly ILogger<DataValueReferenceFactoryCollection> _logger;
1917

20-
/// <summary>
21-
/// Initializes a new instance of the <see cref="DataValueReferenceFactoryCollection" /> class.
22-
/// </summary>
23-
/// <param name="items">The items.</param>
24-
[Obsolete("Please use the constructor taking all parameters. Scheduled for removal in Umbraco 17.")]
25-
public DataValueReferenceFactoryCollection(Func<IEnumerable<IDataValueReferenceFactory>> items)
26-
: this(
27-
items,
28-
StaticServiceProvider.Instance.GetRequiredService<ILogger<DataValueReferenceFactoryCollection>>())
29-
{ }
30-
3118
/// <summary>
3219
/// Initializes a new instance of the <see cref="DataValueReferenceFactoryCollection" /> class.
3320
/// </summary>
@@ -159,17 +146,6 @@ private IEnumerable<UmbracoEntityReference> GetReferencesFromPropertyValues(IEnu
159146
return result;
160147
}
161148

162-
/// <summary>
163-
/// Gets all relation type aliases that are automatically tracked.
164-
/// </summary>
165-
/// <param name="propertyEditors">The property editors.</param>
166-
/// <returns>
167-
/// All relation type aliases that are automatically tracked.
168-
/// </returns>
169-
[Obsolete("Use GetAllAutomaticRelationTypesAliases. This will be removed in Umbraco 15.")]
170-
public ISet<string> GetAutomaticRelationTypesAliases(PropertyEditorCollection propertyEditors) =>
171-
GetAllAutomaticRelationTypesAliases(propertyEditors);
172-
173149
public ISet<string> GetAllAutomaticRelationTypesAliases(PropertyEditorCollection propertyEditors)
174150
{
175151
// Always add default automatic relation types

src/Umbraco.Core/PropertyEditors/RadioValueEditor.cs

Lines changed: 0 additions & 18 deletions
This file was deleted.

src/Umbraco.Core/PropertyEditors/Validators/EmailValidator.cs

Lines changed: 0 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -14,15 +14,6 @@ public sealed class EmailValidator : IValueValidator
1414
{
1515
private readonly ILocalizedTextService _localizedTextService;
1616

17-
/// <summary>
18-
/// Initializes a new instance of the <see cref="EmailValidator"/> class.
19-
/// </summary>
20-
[Obsolete("Please use the constructor taking all parameters. Scheduled for removal in Umbraco 17.")]
21-
public EmailValidator()
22-
: this(StaticServiceProvider.Instance.GetRequiredService<ILocalizedTextService>())
23-
{
24-
}
25-
2617
/// <summary>
2718
/// Initializes a new instance of the <see cref="EmailValidator"/> class.
2819
/// </summary>

src/Umbraco.Core/PropertyEditors/Validators/MultipleValueValidator.cs

Lines changed: 0 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -14,15 +14,6 @@ public class MultipleValueValidator : IValueValidator
1414
{
1515
private readonly ILocalizedTextService _localizedTextService;
1616

17-
/// <summary>
18-
/// Initializes a new instance of the <see cref="MultipleValueValidator"/> class.
19-
/// </summary>
20-
[Obsolete("Please use the constructor that takes all parameters. Scheduled for removal in Umbraco 17.")]
21-
public MultipleValueValidator()
22-
: this(StaticServiceProvider.Instance.GetRequiredService<ILocalizedTextService>())
23-
{
24-
}
25-
2617
/// <summary>
2718
/// Initializes a new instance of the <see cref="MultipleValueValidator"/> class.
2819
/// </summary>

src/Umbraco.Core/PropertyEditors/Validators/RadioValueValidator.cs

Lines changed: 0 additions & 35 deletions
This file was deleted.

src/Umbraco.Core/PublishedCache/IPublishedCache.cs

Lines changed: 0 additions & 55 deletions
Original file line numberDiff line numberDiff line change
@@ -25,16 +25,6 @@ public interface IPublishedCache
2525
/// <remarks>The value of <paramref name="preview" /> overrides defaults.</remarks>
2626
IPublishedContent? GetById(bool preview, Guid contentId);
2727

28-
/// <summary>
29-
/// Gets a content identified by its Udi identifier.
30-
/// </summary>
31-
/// <param name="preview">A value indicating whether to consider unpublished content.</param>
32-
/// <param name="contentId">The content Udi identifier.</param>
33-
/// <returns>The content, or null.</returns>
34-
/// <remarks>The value of <paramref name="preview" /> overrides defaults.</remarks>
35-
[Obsolete] // FIXME: Remove when replacing nucache
36-
IPublishedContent? GetById(bool preview, Udi contentId);
37-
3828
/// <summary>
3929
/// Gets a content identified by its unique identifier.
4030
/// </summary>
@@ -50,49 +40,4 @@ public interface IPublishedCache
5040
/// <returns>The content, or null.</returns>
5141
/// <remarks>Considers published or unpublished content depending on defaults.</remarks>
5242
IPublishedContent? GetById(Guid contentId);
53-
54-
/// <summary>
55-
/// Gets a content identified by its unique identifier.
56-
/// </summary>
57-
/// <param name="contentId">The content unique identifier.</param>
58-
/// <returns>The content, or null.</returns>
59-
/// <remarks>Considers published or unpublished content depending on defaults.</remarks>
60-
[Obsolete] // FIXME: Remove when replacing nucache
61-
IPublishedContent? GetById(Udi contentId);
62-
63-
/// <summary>
64-
/// Gets contents at root.
65-
/// </summary>
66-
/// <param name="preview">A value indicating whether to consider unpublished content.</param>
67-
/// <param name="culture">A culture.</param>
68-
/// <returns>The contents.</returns>
69-
/// <remarks>The value of <paramref name="preview" /> overrides defaults.</remarks>
70-
[Obsolete("Scheduled for removal, use IDocumentNavigationQueryService instead in v17")]
71-
IEnumerable<IPublishedContent> GetAtRoot(bool preview, string? culture = null);
72-
73-
/// <summary>
74-
/// Gets contents at root.
75-
/// </summary>
76-
/// <param name="culture">A culture.</param>
77-
/// <returns>The contents.</returns>
78-
/// <remarks>Considers published or unpublished content depending on defaults.</remarks>
79-
[Obsolete("Scheduled for removal, use IDocumentNavigationQueryService instead in v17")]
80-
IEnumerable<IPublishedContent> GetAtRoot(string? culture = null);
81-
82-
/// <summary>
83-
/// Gets a value indicating whether the cache contains published content.
84-
/// </summary>
85-
/// <param name="preview">A value indicating whether to consider unpublished content.</param>
86-
/// <returns>A value indicating whether the cache contains published content.</returns>
87-
/// <remarks>The value of <paramref name="preview" /> overrides defaults.</remarks>
88-
[Obsolete("Scheduled for removal in v17")]
89-
bool HasContent(bool preview);
90-
91-
/// <summary>
92-
/// Gets a value indicating whether the cache contains published content.
93-
/// </summary>
94-
/// <returns>A value indicating whether the cache contains published content.</returns>
95-
/// <remarks>Considers published or unpublished content depending on defaults.</remarks>
96-
[Obsolete("Scheduled for removal in v17")]
97-
bool HasContent();
9843
}

0 commit comments

Comments
 (0)