Skip to content

Commit 1258962

Browse files
nikolajlauridsenbergmaniaelit0451kjac
authored
V15: Remove Nucache (#17166)
* Remove nucache reference from Web.Common * Get tests building-ish * Move ReservedFieldNamesService to the right project * Remove IPublishedSnapshotStatus * Added functionality to the INavigationQueryService to get root keys * Fixed issue with navigation * Remove IPublishedSnapshot from UmbracoContext * Begin removing usage of IPublishedSnapshot from PublishedContentExtensions * Fix PublishedContentExtensions.cs * Don't use snapshots in delivery media api * Use IPublishedMediaCache in QueryMediaApiController * Remove more usages of IPublishedSnapshotAccessor * Comment out tests * Remove more usages of PublishedSnapshotAccessor * Remove PublishedSnapshot from property * Fixed test build * Fix errors * Fix some tests * Delete NuCache 🎉 * Implement DatabaseCacheRebuilder * Remove usage of IPublishedSnapshotService * Remove IPublishedSnapshotService * Remove TestPublishedSnapshotAccessor and make tests build * Don't test Snapshot cachelevel It's no longer supported * Fix BlockEditorConverter Element != Element document type * Remember to set cachemanager * Fix RichTextParserTests * Implement TryGetLevel on INavigationQueryService * Fake level and obsolete it in PublishedContent * Remove ChildrenForAllCultures * Hack Path property on PublishedContent * Remove usages of IPublishedSnapshot in tests * More ConvertersTests * Add hybrid cache to integration tests We can actually do this now because we no longer save files on disk * Rename IPublishedSnapshotRebuilder to ICacheRebuilder * Comment out tests * V15: Replacing the usages of Parent (navigation data) from IPublishedContent (#17125) * Fix .Parent references in PublishedContentExtensions * Add missing methods to FriendlyPublishedContentExtensions (ones that you were able to call on the content directly as they now require extra params) * Fix references from the extension methods * Fix dependencies in tests * Replace IPublishedSnapshotAccessor with the content cache in tests * Resolving more .Parent references * Fix unit tests * Obsolete and use extension methods * Remove private method and use extension instead * Moving code around * Fix tests * Fix more references * Cleanup * Fix more usages * Resolve merge conflict * Fix tests * Cleanup * Fix more tests * Fixed unit tests * Cleanup * Replace last usages --------- Co-authored-by: Bjarke Berg <[email protected]> * Remove usage of IPublishedSnapshotAccessor from IRequestItemProvider * Post merge fixup * Remo IPublishedSnapshot * Add HasAny to IDocumentUrlService * Fix TextBuilder * Fix modelsbuilder tests * Use explicit types * Implement GetByContentType * Support element types in PublishedContentTypeCache * Run enlistments before publishing notifications * Fix elements cache refreshing * Implement GetByUdi * Implement GetAtRoot * Implement GetByRoute * Reimplement GetRouteById * Fix blocks unit tests * Initialize domain cache on boot * Only return routes with domains on non default lanauges * V15: Replacing the usages of `Children` (navigation data) from `IPublishedContent` (#17159) * Update params in PublishedContentExtensions to the general interfaces for the published cache and navigation service, so that we can use the extension methods on both documents and media * Introduce GetParent() which uses the right services * Fix obsolete message on .Parent * Obsolete .Children * Fix usages of Children for ApiMediaQueryService * Fix usage in internal * Fix usages in views * Fix indentation * Fix issue with delete language * Update nuget pacakges * Clear elements cache when content is deleted instead of trying to update it * Reset publishedModelFactory * Fixed publishing --------- Co-authored-by: Bjarke Berg <[email protected]> Co-authored-by: Elitsa Marinovska <[email protected]> Co-authored-by: kjac <[email protected]>
1 parent 7ca9642 commit 1258962

File tree

270 files changed

+12053
-21517
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

270 files changed

+12053
-21517
lines changed

Directory.Packages.props

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -47,10 +47,10 @@
4747
<PackageVersion Include="Dazinator.Extensions.FileProviders" Version="2.0.0" />
4848
<PackageVersion Include="Examine" Version="3.3.0" />
4949
<PackageVersion Include="Examine.Core" Version="3.3.0" />
50-
<PackageVersion Include="HtmlAgilityPack" Version="1.11.66" />
50+
<PackageVersion Include="HtmlAgilityPack" Version="1.11.67" />
5151
<PackageVersion Include="JsonPatch.Net" Version="3.1.1" />
5252
<PackageVersion Include="K4os.Compression.LZ4" Version="1.3.8" />
53-
<PackageVersion Include="MailKit" Version="4.7.1.1" />
53+
<PackageVersion Include="MailKit" Version="4.8.0" />
5454
<PackageVersion Include="Markdown" Version="2.2.1" />
5555
<PackageVersion Include="MessagePack" Version="2.5.172" />
5656
<PackageVersion Include="MiniProfiler.AspNetCore.Mvc" Version="4.3.8" />
@@ -61,7 +61,7 @@
6161
<PackageVersion Include="OpenIddict.Abstractions" Version="5.8.0" />
6262
<PackageVersion Include="OpenIddict.AspNetCore" Version="5.8.0" />
6363
<PackageVersion Include="OpenIddict.EntityFrameworkCore" Version="5.8.0" />
64-
<PackageVersion Include="Serilog" Version="4.0.1" />
64+
<PackageVersion Include="Serilog" Version="4.0.2" />
6565
<PackageVersion Include="Serilog.AspNetCore" Version="8.0.2" />
6666
<PackageVersion Include="Serilog.Enrichers.Process" Version="3.0.0" />
6767
<PackageVersion Include="Serilog.Enrichers.Thread" Version="4.0.0" />
@@ -75,12 +75,12 @@
7575
<PackageVersion Include="Serilog.Sinks.Map" Version="2.0.0" />
7676
<PackageVersion Include="SixLabors.ImageSharp" Version="3.1.5" />
7777
<PackageVersion Include="SixLabors.ImageSharp.Web" Version="3.1.3" />
78-
<PackageVersion Include="Swashbuckle.AspNetCore" Version="6.8.0" />
78+
<PackageVersion Include="Swashbuckle.AspNetCore" Version="6.8.1" />
7979
</ItemGroup>
8080
<!-- Transitive pinned versions (only required because our direct dependencies have vulnerable versions of transitive dependencies) -->
8181
<ItemGroup>
8282
<!-- Both Microsoft.EntityFrameworkCore.SqlServer and NPoco.SqlServer bring in a vulnerable version of Azure.Identity -->
83-
<PackageVersion Include="Azure.Identity" Version="1.12.0" />
83+
<PackageVersion Include="Azure.Identity" Version="1.12.1" />
8484
<!-- Dazinator.Extensions.FileProviders brings in a vulnerable version of System.Net.Http -->
8585
<PackageVersion Include="System.Net.Http" Version="4.3.4" />
8686
<!-- Examine brings in a vulnerable version of System.Security.Cryptography.Xml -->
@@ -91,7 +91,6 @@
9191
<PackageVersion Include="Microsoft.IdentityModel.JsonWebTokens" Version="8.1.0" />
9292
<!-- Both Azure.Identity, Microsoft.EntityFrameworkCore.SqlServer, Dazinator.Extensions.FileProviders bring in legacy versions of System.Text.Encodings.Web -->
9393
<PackageVersion Include="System.Text.Encodings.Web" Version="8.0.0" />
94-
9594
<!-- NPoco.SqlServer bring in vulnerable version of Microsoft.Data.SqlClient -->
9695
<PackageVersion Include="Microsoft.Data.SqlClient" Version="5.2.2" />
9796
</ItemGroup>

src/Umbraco.Cms.Api.Delivery/Controllers/Media/ByIdMediaApiController.cs

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,8 +12,10 @@ namespace Umbraco.Cms.Api.Delivery.Controllers.Media;
1212
[ApiVersion("2.0")]
1313
public class ByIdMediaApiController : MediaApiControllerBase
1414
{
15-
public ByIdMediaApiController(IPublishedSnapshotAccessor publishedSnapshotAccessor, IApiMediaWithCropsResponseBuilder apiMediaWithCropsResponseBuilder)
16-
: base(publishedSnapshotAccessor, apiMediaWithCropsResponseBuilder)
15+
public ByIdMediaApiController(
16+
IPublishedMediaCache publishedMediaCache,
17+
IApiMediaWithCropsResponseBuilder apiMediaWithCropsResponseBuilder)
18+
: base(publishedMediaCache, apiMediaWithCropsResponseBuilder)
1719
{
1820
}
1921

src/Umbraco.Cms.Api.Delivery/Controllers/Media/ByIdsMediaApiController.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,8 +13,8 @@ namespace Umbraco.Cms.Api.Delivery.Controllers.Media;
1313
[ApiVersion("2.0")]
1414
public class ByIdsMediaApiController : MediaApiControllerBase
1515
{
16-
public ByIdsMediaApiController(IPublishedSnapshotAccessor publishedSnapshotAccessor, IApiMediaWithCropsResponseBuilder apiMediaWithCropsResponseBuilder)
17-
: base(publishedSnapshotAccessor, apiMediaWithCropsResponseBuilder)
16+
public ByIdsMediaApiController(IPublishedMediaCache publishedMediaCache, IApiMediaWithCropsResponseBuilder apiMediaWithCropsResponseBuilder)
17+
: base(publishedMediaCache, apiMediaWithCropsResponseBuilder)
1818
{
1919
}
2020

src/Umbraco.Cms.Api.Delivery/Controllers/Media/ByPathMediaApiController.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,10 +16,10 @@ public class ByPathMediaApiController : MediaApiControllerBase
1616
private readonly IApiMediaQueryService _apiMediaQueryService;
1717

1818
public ByPathMediaApiController(
19-
IPublishedSnapshotAccessor publishedSnapshotAccessor,
19+
IPublishedMediaCache publishedMediaCache,
2020
IApiMediaWithCropsResponseBuilder apiMediaWithCropsResponseBuilder,
2121
IApiMediaQueryService apiMediaQueryService)
22-
: base(publishedSnapshotAccessor, apiMediaWithCropsResponseBuilder)
22+
: base(publishedMediaCache, apiMediaWithCropsResponseBuilder)
2323
=> _apiMediaQueryService = apiMediaQueryService;
2424

2525
[HttpGet("item/{*path}")]

src/Umbraco.Cms.Api.Delivery/Controllers/Media/MediaApiControllerBase.cs

Lines changed: 4 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -20,18 +20,15 @@ namespace Umbraco.Cms.Api.Delivery.Controllers.Media;
2020
public abstract class MediaApiControllerBase : DeliveryApiControllerBase
2121
{
2222
private readonly IApiMediaWithCropsResponseBuilder _apiMediaWithCropsResponseBuilder;
23-
private readonly IPublishedSnapshotAccessor _publishedSnapshotAccessor;
24-
private IPublishedMediaCache? _publishedMediaCache;
23+
private IPublishedMediaCache _publishedMediaCache;
2524

26-
protected MediaApiControllerBase(IPublishedSnapshotAccessor publishedSnapshotAccessor, IApiMediaWithCropsResponseBuilder apiMediaWithCropsResponseBuilder)
25+
protected MediaApiControllerBase(IPublishedMediaCache publishedMediaCache, IApiMediaWithCropsResponseBuilder apiMediaWithCropsResponseBuilder)
2726
{
28-
_publishedSnapshotAccessor = publishedSnapshotAccessor;
27+
_publishedMediaCache = publishedMediaCache;
2928
_apiMediaWithCropsResponseBuilder = apiMediaWithCropsResponseBuilder;
3029
}
3130

32-
protected IPublishedMediaCache PublishedMediaCache => _publishedMediaCache
33-
??= _publishedSnapshotAccessor.GetRequiredPublishedSnapshot().Media
34-
?? throw new InvalidOperationException("Could not obtain the published media cache");
31+
protected IPublishedMediaCache PublishedMediaCache => _publishedMediaCache;
3532

3633
protected IApiMediaWithCropsResponse BuildApiMediaWithCrops(IPublishedContent media)
3734
=> _apiMediaWithCropsResponseBuilder.Build(media);

src/Umbraco.Cms.Api.Delivery/Controllers/Media/QueryMediaApiController.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -21,10 +21,10 @@ public class QueryMediaApiController : MediaApiControllerBase
2121
private readonly IApiMediaQueryService _apiMediaQueryService;
2222

2323
public QueryMediaApiController(
24-
IPublishedSnapshotAccessor publishedSnapshotAccessor,
24+
IPublishedMediaCache publishedMediaCache,
2525
IApiMediaWithCropsResponseBuilder apiMediaWithCropsResponseBuilder,
2626
IApiMediaQueryService apiMediaQueryService)
27-
: base(publishedSnapshotAccessor, apiMediaWithCropsResponseBuilder)
27+
: base(publishedMediaCache, apiMediaWithCropsResponseBuilder)
2828
=> _apiMediaQueryService = apiMediaQueryService;
2929

3030
[HttpGet]

src/Umbraco.Cms.Api.Delivery/Querying/QueryOptionBase.cs

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -7,14 +7,15 @@ namespace Umbraco.Cms.Api.Delivery.Querying;
77

88
public abstract class QueryOptionBase
99
{
10-
private readonly IPublishedSnapshotAccessor _publishedSnapshotAccessor;
10+
private readonly IPublishedContentCache _publishedContentCache;
1111
private readonly IRequestRoutingService _requestRoutingService;
1212

13+
1314
public QueryOptionBase(
14-
IPublishedSnapshotAccessor publishedSnapshotAccessor,
15+
IPublishedContentCache publishedContentCache,
1516
IRequestRoutingService requestRoutingService)
1617
{
17-
_publishedSnapshotAccessor = publishedSnapshotAccessor;
18+
_publishedContentCache = publishedContentCache;
1819
_requestRoutingService = requestRoutingService;
1920
}
2021

@@ -30,11 +31,9 @@ public QueryOptionBase(
3031
return id;
3132
}
3233

33-
IPublishedSnapshot publishedSnapshot = _publishedSnapshotAccessor.GetRequiredPublishedSnapshot();
34-
3534
// Check if the passed value is a path of a content item
3635
var contentRoute = _requestRoutingService.GetContentRoute(queryStringValue);
37-
IPublishedContent? contentItem = publishedSnapshot.Content?.GetByRoute(contentRoute);
36+
IPublishedContent? contentItem = _publishedContentCache.GetByRoute(contentRoute);
3837

3938
return contentItem?.Key;
4039
}

src/Umbraco.Cms.Api.Delivery/Querying/Selectors/AncestorsSelector.cs

Lines changed: 22 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,19 +1,35 @@
1+
using Microsoft.Extensions.DependencyInjection;
12
using Umbraco.Cms.Api.Delivery.Indexing.Selectors;
23
using Umbraco.Cms.Core.DeliveryApi;
4+
using Umbraco.Cms.Core.DependencyInjection;
35
using Umbraco.Cms.Core.Models.PublishedContent;
46
using Umbraco.Cms.Core.PublishedCache;
7+
using Umbraco.Cms.Core.Services.Navigation;
58
using Umbraco.Extensions;
69

710
namespace Umbraco.Cms.Api.Delivery.Querying.Selectors;
811

912
public sealed class AncestorsSelector : QueryOptionBase, ISelectorHandler
1013
{
14+
private readonly IPublishedContentCache _publishedContentCache;
15+
private readonly IDocumentNavigationQueryService _navigationQueryService;
1116
private const string AncestorsSpecifier = "ancestors:";
12-
private readonly IPublishedSnapshotAccessor _publishedSnapshotAccessor;
1317

14-
public AncestorsSelector(IPublishedSnapshotAccessor publishedSnapshotAccessor, IRequestRoutingService requestRoutingService)
15-
: base(publishedSnapshotAccessor, requestRoutingService) =>
16-
_publishedSnapshotAccessor = publishedSnapshotAccessor;
18+
public AncestorsSelector(
19+
IPublishedContentCache publishedContentCache,
20+
IRequestRoutingService requestRoutingService,
21+
IDocumentNavigationQueryService navigationQueryService)
22+
: base(publishedContentCache, requestRoutingService)
23+
{
24+
_publishedContentCache = publishedContentCache;
25+
_navigationQueryService = navigationQueryService;
26+
}
27+
28+
[Obsolete("Use the constructor that takes all parameters. Scheduled for removal in V17.")]
29+
public AncestorsSelector(IPublishedContentCache publishedContentCache, IRequestRoutingService requestRoutingService)
30+
: this(publishedContentCache, requestRoutingService, StaticServiceProvider.Instance.GetRequiredService<IDocumentNavigationQueryService>())
31+
{
32+
}
1733

1834
/// <inheritdoc />
1935
public bool CanHandle(string query)
@@ -37,12 +53,10 @@ public SelectorOption BuildSelectorOption(string selector)
3753
};
3854
}
3955

40-
IPublishedSnapshot publishedSnapshot = _publishedSnapshotAccessor.GetRequiredPublishedSnapshot();
41-
42-
IPublishedContent contentItem = publishedSnapshot.Content?.GetById((Guid)id)
56+
IPublishedContent contentItem = _publishedContentCache.GetById((Guid)id)
4357
?? throw new InvalidOperationException("Could not obtain the content cache");
4458

45-
var ancestorKeys = contentItem.Ancestors().Select(a => a.Key.ToString("D")).ToArray();
59+
var ancestorKeys = contentItem.Ancestors(_publishedContentCache, _navigationQueryService).Select(a => a.Key.ToString("D")).ToArray();
4660

4761
return new SelectorOption
4862
{

src/Umbraco.Cms.Api.Delivery/Querying/Selectors/ChildrenSelector.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,8 +9,8 @@ public sealed class ChildrenSelector : QueryOptionBase, ISelectorHandler
99
{
1010
private const string ChildrenSpecifier = "children:";
1111

12-
public ChildrenSelector(IPublishedSnapshotAccessor publishedSnapshotAccessor, IRequestRoutingService requestRoutingService)
13-
: base(publishedSnapshotAccessor, requestRoutingService)
12+
public ChildrenSelector(IPublishedContentCache publishedContentCache, IRequestRoutingService requestRoutingService)
13+
: base(publishedContentCache, requestRoutingService)
1414
{
1515
}
1616

src/Umbraco.Cms.Api.Delivery/Querying/Selectors/DescendantsSelector.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,8 +9,8 @@ public sealed class DescendantsSelector : QueryOptionBase, ISelectorHandler
99
{
1010
private const string DescendantsSpecifier = "descendants:";
1111

12-
public DescendantsSelector(IPublishedSnapshotAccessor publishedSnapshotAccessor, IRequestRoutingService requestRoutingService)
13-
: base(publishedSnapshotAccessor, requestRoutingService)
12+
public DescendantsSelector(IPublishedContentCache publishedContentCache, IRequestRoutingService requestRoutingService)
13+
: base(publishedContentCache, requestRoutingService)
1414
{
1515
}
1616

0 commit comments

Comments
 (0)