From 57020b47789829986b4f55ceb54e9d41bc45979f Mon Sep 17 00:00:00 2001 From: Shannon Date: Tue, 22 Dec 2020 12:33:00 +1100 Subject: [PATCH] adds notes, removes IPublishedCacheComposer --- .../Composing/IPublishedCacheComposer .cs | 5 ----- .../Runtime/CoreRuntime.cs | 3 +++ .../Compose/DisabledModelsBuilderComponent.cs | 6 +++++- .../Compose/ModelsBuilderComposer.cs | 2 +- .../PublishedSnapshotServiceEventHandler.cs | 2 +- .../Services/ContentTypeServiceVariantsTests.cs | 2 +- .../Controllers/ContentTypeController.cs | 17 ----------------- .../Filters/JsonDateTimeFormatAttribute.cs | 16 ++++++++-------- .../Middleware/UmbracoRequestMiddleware.cs | 2 +- 9 files changed, 20 insertions(+), 35 deletions(-) delete mode 100644 src/Umbraco.Core/Composing/IPublishedCacheComposer .cs diff --git a/src/Umbraco.Core/Composing/IPublishedCacheComposer .cs b/src/Umbraco.Core/Composing/IPublishedCacheComposer .cs deleted file mode 100644 index d88eb44ea3..0000000000 --- a/src/Umbraco.Core/Composing/IPublishedCacheComposer .cs +++ /dev/null @@ -1,5 +0,0 @@ -namespace Umbraco.Core.Composing -{ - public interface IPublishedCacheComposer : ICoreComposer - { } -} diff --git a/src/Umbraco.Infrastructure/Runtime/CoreRuntime.cs b/src/Umbraco.Infrastructure/Runtime/CoreRuntime.cs index 35b7443338..a05c1a7f98 100644 --- a/src/Umbraco.Infrastructure/Runtime/CoreRuntime.cs +++ b/src/Umbraco.Infrastructure/Runtime/CoreRuntime.cs @@ -23,6 +23,9 @@ namespace Umbraco.Infrastructure.Runtime private readonly IEventAggregator _eventAggregator; private readonly IHostingEnvironment _hostingEnvironment; + /// + /// Initializes a new instance of the class. + /// public CoreRuntime( ILoggerFactory loggerFactory, IRuntimeState state, diff --git a/src/Umbraco.ModelsBuilder.Embedded/Compose/DisabledModelsBuilderComponent.cs b/src/Umbraco.ModelsBuilder.Embedded/Compose/DisabledModelsBuilderComponent.cs index 2031a23af5..f7fab098b0 100644 --- a/src/Umbraco.ModelsBuilder.Embedded/Compose/DisabledModelsBuilderComponent.cs +++ b/src/Umbraco.ModelsBuilder.Embedded/Compose/DisabledModelsBuilderComponent.cs @@ -1,9 +1,13 @@ -using Umbraco.Core.Composing; +using Umbraco.Core.Composing; using Umbraco.ModelsBuilder.Embedded.BackOffice; using Umbraco.Web.Features; namespace Umbraco.ModelsBuilder.Embedded.Compose { + // TODO: This needs to die, see TODO in ModelsBuilderComposer. This is also no longer used in this netcore + // codebase. Potentially this could be changed to ext methods if necessary that could be used by end users who will + // install the community MB package to disable any built in MB stuff. + /// /// Special component used for when MB is disabled with the legacy MB is detected /// diff --git a/src/Umbraco.ModelsBuilder.Embedded/Compose/ModelsBuilderComposer.cs b/src/Umbraco.ModelsBuilder.Embedded/Compose/ModelsBuilderComposer.cs index 344e1b025a..ca597a607b 100644 --- a/src/Umbraco.ModelsBuilder.Embedded/Compose/ModelsBuilderComposer.cs +++ b/src/Umbraco.ModelsBuilder.Embedded/Compose/ModelsBuilderComposer.cs @@ -12,7 +12,7 @@ using Umbraco.Core.DependencyInjection; namespace Umbraco.ModelsBuilder.Embedded.Compose { // TODO: We'll need to change this stuff to IUmbracoBuilder ext and control the order of things there - [ComposeBefore(typeof(IPublishedCacheComposer))] + // This needs to execute before the AddNuCache call public sealed class ModelsBuilderComposer : ICoreComposer { public void Compose(IUmbracoBuilder builder) diff --git a/src/Umbraco.PublishedCache.NuCache/PublishedSnapshotServiceEventHandler.cs b/src/Umbraco.PublishedCache.NuCache/PublishedSnapshotServiceEventHandler.cs index 084ed569ca..2c37356191 100644 --- a/src/Umbraco.PublishedCache.NuCache/PublishedSnapshotServiceEventHandler.cs +++ b/src/Umbraco.PublishedCache.NuCache/PublishedSnapshotServiceEventHandler.cs @@ -38,7 +38,7 @@ namespace Umbraco.Web.PublishedCache.NuCache /// Binds to the Umbraco events /// /// Returns true if binding occurred - public bool Start() + public bool Initialize() { // however, the cache is NOT available until we are configured, because loading // content (and content types) from database cannot be consistent (see notes in "Handle diff --git a/src/Umbraco.Tests.Integration/Umbraco.Infrastructure/Services/ContentTypeServiceVariantsTests.cs b/src/Umbraco.Tests.Integration/Umbraco.Infrastructure/Services/ContentTypeServiceVariantsTests.cs index 995e4d60ae..5e50f570ab 100644 --- a/src/Umbraco.Tests.Integration/Umbraco.Infrastructure/Services/ContentTypeServiceVariantsTests.cs +++ b/src/Umbraco.Tests.Integration/Umbraco.Infrastructure/Services/ContentTypeServiceVariantsTests.cs @@ -42,7 +42,7 @@ namespace Umbraco.Tests.Integration.Umbraco.Infrastructure.Services // Ensure that the events are bound on each test PublishedSnapshotServiceEventHandler eventBinder = host.Services.GetRequiredService(); - eventBinder.Start(); + eventBinder.Initialize(); } private void AssertJsonStartsWith(int id, string expected) diff --git a/src/Umbraco.Web.BackOffice/Controllers/ContentTypeController.cs b/src/Umbraco.Web.BackOffice/Controllers/ContentTypeController.cs index 05e4db5daa..50be27a108 100644 --- a/src/Umbraco.Web.BackOffice/Controllers/ContentTypeController.cs +++ b/src/Umbraco.Web.BackOffice/Controllers/ContentTypeController.cs @@ -114,8 +114,6 @@ namespace Umbraco.Web.BackOffice.Controllers /// /// Gets the document type a given id /// - /// - /// [DetermineAmbiguousActionByPassingParameters] [Authorize(Policy = AuthorizationPolicies.TreeAccessDocumentTypes)] public DocumentTypeDisplay GetById(int id) @@ -133,8 +131,6 @@ namespace Umbraco.Web.BackOffice.Controllers /// /// Gets the document type a given guid /// - /// - /// [DetermineAmbiguousActionByPassingParameters] [Authorize(Policy = AuthorizationPolicies.TreeAccessDocumentTypes)] public DocumentTypeDisplay GetById(Guid id) @@ -152,8 +148,6 @@ namespace Umbraco.Web.BackOffice.Controllers /// /// Gets the document type a given udi /// - /// - /// [DetermineAmbiguousActionByPassingParameters] [Authorize(Policy = AuthorizationPolicies.TreeAccessDocumentTypes)] public DocumentTypeDisplay GetById(Udi id) @@ -175,8 +169,6 @@ namespace Umbraco.Web.BackOffice.Controllers /// /// Deletes a document type with a given ID /// - /// - /// [HttpDelete] [HttpPost] [Authorize(Policy = AuthorizationPolicies.TreeAccessDocumentTypes)] @@ -195,7 +187,6 @@ namespace Umbraco.Web.BackOffice.Controllers /// /// Gets all user defined properties. /// - /// [Authorize(Policy = AuthorizationPolicies.TreeAccessAnyContentOrTypes)] public IEnumerable GetAllPropertyTypeAliases() { @@ -205,7 +196,6 @@ namespace Umbraco.Web.BackOffice.Controllers /// /// Gets all the standard fields. /// - /// [Authorize(Policy = AuthorizationPolicies.TreeAccessAnyContentOrTypes)] public IEnumerable GetAllStandardFields() { @@ -217,8 +207,6 @@ namespace Umbraco.Web.BackOffice.Controllers /// Returns the available compositions for this content type /// This has been wrapped in a dto instead of simple parameters to support having multiple parameters in post request body /// - /// - /// [HttpPost] [Authorize(Policy = AuthorizationPolicies.TreeAccessDocumentTypes)] public IActionResult GetAvailableCompositeContentTypes(GetAvailableCompositionsFilter filter) @@ -235,7 +223,6 @@ namespace Umbraco.Web.BackOffice.Controllers /// /// Returns true if any content types have culture variation enabled /// - /// [HttpGet] [Authorize(Policy = AuthorizationPolicies.BackOfficeAccess)] public bool AllowsCultureVariation() @@ -248,8 +235,6 @@ namespace Umbraco.Web.BackOffice.Controllers /// Returns where a particular composition has been used /// This has been wrapped in a dto instead of simple parameters to support having multiple parameters in post request body /// - /// - /// [HttpPost] [Authorize(Policy = AuthorizationPolicies.TreeAccessDocumentTypes)] public IActionResult GetWhereCompositionIsUsedInContentTypes(GetAvailableCompositionsFilter filter) @@ -287,8 +272,6 @@ namespace Umbraco.Web.BackOffice.Controllers /// /// Deletes a document type container with a given ID /// - /// - /// [HttpDelete] [HttpPost] [Authorize(Policy = AuthorizationPolicies.TreeAccessDocumentTypes)] diff --git a/src/Umbraco.Web.Common/Filters/JsonDateTimeFormatAttribute.cs b/src/Umbraco.Web.Common/Filters/JsonDateTimeFormatAttribute.cs index 031aeb1f4c..edf8489f12 100644 --- a/src/Umbraco.Web.Common/Filters/JsonDateTimeFormatAttribute.cs +++ b/src/Umbraco.Web.Common/Filters/JsonDateTimeFormatAttribute.cs @@ -13,24 +13,24 @@ namespace Umbraco.Web.Common.Filters /// /// Applying this attribute to any controller will ensure that it only contains one json formatter compatible with the angular json vulnerability prevention. /// - public class JsonDateTimeFormatAttribute : TypeFilterAttribute + public sealed class JsonDateTimeFormatAttribute : TypeFilterAttribute { - public JsonDateTimeFormatAttribute() : base(typeof(JsonDateTimeFormatFilter)) - { - Order = 2; //must be higher than AngularJsonOnlyConfigurationAttribute.Order - } + /// + /// Initializes a new instance of the class. + /// + public JsonDateTimeFormatAttribute() + : base(typeof(JsonDateTimeFormatFilter)) => + Order = 2; // must be higher than AngularJsonOnlyConfigurationAttribute.Order private class JsonDateTimeFormatFilter : IResultFilter { private readonly string _format = "yyyy-MM-dd HH:mm:ss"; - private readonly IOptions _mvcNewtonsoftJsonOptions; private readonly ArrayPool _arrayPool; private readonly IOptions _options; - public JsonDateTimeFormatFilter(IOptions mvcNewtonsoftJsonOptions, ArrayPool arrayPool, IOptions options) + public JsonDateTimeFormatFilter(ArrayPool arrayPool, IOptions options) { - _mvcNewtonsoftJsonOptions = mvcNewtonsoftJsonOptions; _arrayPool = arrayPool; _options = options; } diff --git a/src/Umbraco.Web.Common/Middleware/UmbracoRequestMiddleware.cs b/src/Umbraco.Web.Common/Middleware/UmbracoRequestMiddleware.cs index 7845962928..35cd2250cb 100644 --- a/src/Umbraco.Web.Common/Middleware/UmbracoRequestMiddleware.cs +++ b/src/Umbraco.Web.Common/Middleware/UmbracoRequestMiddleware.cs @@ -172,7 +172,7 @@ namespace Umbraco.Web.Common.Middleware ref s_cacheInitializedLock, () => { - _publishedSnapshotServiceEventHandler.Start(); + _publishedSnapshotServiceEventHandler.Initialize(); return true; }); }