diff --git a/src/Umbraco.Core/Services/IRuntime.cs b/src/Umbraco.Core/Services/IRuntime.cs index b10c9fe90f..3455835c8e 100644 --- a/src/Umbraco.Core/Services/IRuntime.cs +++ b/src/Umbraco.Core/Services/IRuntime.cs @@ -1,3 +1,4 @@ +using System.Threading; using Microsoft.Extensions.Hosting; namespace Umbraco.Cms.Core.Services @@ -11,5 +12,7 @@ namespace Umbraco.Cms.Core.Services /// Gets the runtime state. /// IRuntimeState State { get; } + + CancellationToken CancellationToken { get; } } } diff --git a/src/Umbraco.Infrastructure/Runtime/CoreRuntime.cs b/src/Umbraco.Infrastructure/Runtime/CoreRuntime.cs index e2b20ced8f..b198b88f59 100644 --- a/src/Umbraco.Infrastructure/Runtime/CoreRuntime.cs +++ b/src/Umbraco.Infrastructure/Runtime/CoreRuntime.cs @@ -66,10 +66,12 @@ namespace Umbraco.Cms.Infrastructure.Runtime /// Gets the state of the Umbraco runtime. /// public IRuntimeState State { get; } + public CancellationToken CancellationToken { get; private set; } /// public async Task StartAsync(CancellationToken cancellationToken) { + CancellationToken = cancellationToken; StaticApplicationLogging.Initialize(_loggerFactory); AppDomain.CurrentDomain.UnhandledException += (_, args) => diff --git a/src/Umbraco.Tests.UnitTests/AutoFixture/AutoMoqDataAttribute.cs b/src/Umbraco.Tests.UnitTests/AutoFixture/AutoMoqDataAttribute.cs index d7fd849e71..3e728a96c9 100644 --- a/src/Umbraco.Tests.UnitTests/AutoFixture/AutoMoqDataAttribute.cs +++ b/src/Umbraco.Tests.UnitTests/AutoFixture/AutoMoqDataAttribute.cs @@ -17,8 +17,8 @@ using Umbraco.Cms.Core.Hosting; using Umbraco.Cms.Core.Security; using Umbraco.Cms.Core.Services; using Umbraco.Cms.Web.BackOffice.Controllers; +using Umbraco.Cms.Web.BackOffice.Install; using Umbraco.Cms.Web.BackOffice.Routing; -using Umbraco.Cms.Web.Common.Install; using Umbraco.Cms.Web.Common.Security; namespace Umbraco.Cms.Tests.UnitTests.AutoFixture diff --git a/src/Umbraco.Tests.UnitTests/Umbraco.Web.Common/FileNameTests.cs b/src/Umbraco.Tests.UnitTests/Umbraco.Web.Common/FileNameTests.cs index 98d4eaee3c..4d7d0a0f26 100644 --- a/src/Umbraco.Tests.UnitTests/Umbraco.Web.Common/FileNameTests.cs +++ b/src/Umbraco.Tests.UnitTests/Umbraco.Web.Common/FileNameTests.cs @@ -15,7 +15,7 @@ using Umbraco.Cms.Core.Configuration.Models; using Umbraco.Cms.Core.Hosting; using Umbraco.Cms.Tests.UnitTests.AutoFixture; using Umbraco.Cms.Web.BackOffice.Controllers; -using Umbraco.Cms.Web.Common.Install; +using Umbraco.Cms.Web.BackOffice.Install; namespace Umbraco.Cms.Tests.UnitTests.Umbraco.Web.Common { diff --git a/src/Umbraco.Tests.UnitTests/Umbraco.Web.Common/Routing/InstallAreaRoutesTests.cs b/src/Umbraco.Tests.UnitTests/Umbraco.Web.Common/Routing/InstallAreaRoutesTests.cs index 0833ba4576..24a272a4fa 100644 --- a/src/Umbraco.Tests.UnitTests/Umbraco.Web.Common/Routing/InstallAreaRoutesTests.cs +++ b/src/Umbraco.Tests.UnitTests/Umbraco.Web.Common/Routing/InstallAreaRoutesTests.cs @@ -9,7 +9,7 @@ using NUnit.Framework; using Umbraco.Cms.Core; using Umbraco.Cms.Core.Hosting; using Umbraco.Cms.Core.Services; -using Umbraco.Cms.Web.Common.Install; +using Umbraco.Cms.Web.BackOffice.Install; using Umbraco.Extensions; using static Umbraco.Cms.Core.Constants.Web.Routing; using Constants = Umbraco.Cms.Core.Constants; diff --git a/src/Umbraco.Web.BackOffice/Controllers/PackageInstallController.cs b/src/Umbraco.Web.BackOffice/Controllers/PackageInstallController.cs index 9404e9a292..1c874732c4 100644 --- a/src/Umbraco.Web.BackOffice/Controllers/PackageInstallController.cs +++ b/src/Umbraco.Web.BackOffice/Controllers/PackageInstallController.cs @@ -317,6 +317,7 @@ namespace Umbraco.Cms.Web.BackOffice.Controllers model.IsRestarting = true; + return model; } diff --git a/src/Umbraco.Web.BackOffice/DependencyInjection/UmbracoBuilderExtensions.cs b/src/Umbraco.Web.BackOffice/DependencyInjection/UmbracoBuilderExtensions.cs index 23a7e3e9b1..3572ee53fc 100644 --- a/src/Umbraco.Web.BackOffice/DependencyInjection/UmbracoBuilderExtensions.cs +++ b/src/Umbraco.Web.BackOffice/DependencyInjection/UmbracoBuilderExtensions.cs @@ -14,6 +14,7 @@ using Umbraco.Cms.Infrastructure.Examine.DependencyInjection; using Umbraco.Cms.Infrastructure.WebAssets; using Umbraco.Cms.Web.BackOffice.Controllers; using Umbraco.Cms.Web.BackOffice.Filters; +using Umbraco.Cms.Web.BackOffice.Install; using Umbraco.Cms.Web.BackOffice.Middleware; using Umbraco.Cms.Web.BackOffice.ModelsBuilder; using Umbraco.Cms.Web.BackOffice.Routing; @@ -54,6 +55,13 @@ namespace Umbraco.Extensions .AddExamine() .AddExamineIndexes(); + public static IUmbracoBuilder AddUnattedInstallCreateUser(this IUmbracoBuilder builder) + { + builder.AddNotificationAsyncHandler(); + return builder; + } + + /// /// Adds Umbraco preview support /// @@ -75,6 +83,7 @@ namespace Umbraco.Extensions builder.Services.AddSingleton(); builder.Services.ConfigureOptions(); builder.Services.AddUnique(); + builder.Services.AddUnique(); builder.Services.AddUnique(); builder.Services.AddUnique(); builder.AddNotificationAsyncHandler(); diff --git a/src/Umbraco.Web.BackOffice/Extensions/LinkGeneratorExtensions.cs b/src/Umbraco.Web.BackOffice/Extensions/LinkGeneratorExtensions.cs new file mode 100644 index 0000000000..23c44e2be4 --- /dev/null +++ b/src/Umbraco.Web.BackOffice/Extensions/LinkGeneratorExtensions.cs @@ -0,0 +1,25 @@ +using Microsoft.AspNetCore.Routing; +using Umbraco.Cms.Web.BackOffice.Install; + +namespace Umbraco.Extensions +{ + public static class BackofficeLinkGeneratorExtensions + { + /// + /// Returns the URL for the installer + /// + public static string GetInstallerUrl(this LinkGenerator linkGenerator) + => linkGenerator.GetPathByAction(nameof(InstallController.Index), ControllerExtensions.GetControllerName(), new { area = Cms.Core.Constants.Web.Mvc.InstallArea }); + + /// + /// Returns the URL for the installer api + /// + public static string GetInstallerApiUrl(this LinkGenerator linkGenerator) + => linkGenerator.GetPathByAction( + nameof(InstallApiController.GetSetup), + ControllerExtensions.GetControllerName(), + new { area = Cms.Core.Constants.Web.Mvc.InstallArea }).TrimEnd(nameof(InstallApiController.GetSetup)); + + + } +} diff --git a/src/Umbraco.Web.Common/Extensions/UmbracoApplicationBuilder.Installer.cs b/src/Umbraco.Web.BackOffice/Extensions/UmbracoApplicationBuilder.Installer.cs similarity index 95% rename from src/Umbraco.Web.Common/Extensions/UmbracoApplicationBuilder.Installer.cs rename to src/Umbraco.Web.BackOffice/Extensions/UmbracoApplicationBuilder.Installer.cs index 3859814775..2be8c6bb28 100644 --- a/src/Umbraco.Web.Common/Extensions/UmbracoApplicationBuilder.Installer.cs +++ b/src/Umbraco.Web.BackOffice/Extensions/UmbracoApplicationBuilder.Installer.cs @@ -1,7 +1,7 @@ using Microsoft.AspNetCore.Builder; using Microsoft.Extensions.DependencyInjection; +using Umbraco.Cms.Web.BackOffice.Install; using Umbraco.Cms.Web.Common.ApplicationBuilder; -using Umbraco.Cms.Web.Common.Install; namespace Umbraco.Extensions { diff --git a/src/Umbraco.Web.Common/Install/CreateUnattendedUserNotificationHandler.cs b/src/Umbraco.Web.BackOffice/Install/CreateUnattendedUserNotificationHandler.cs similarity index 98% rename from src/Umbraco.Web.Common/Install/CreateUnattendedUserNotificationHandler.cs rename to src/Umbraco.Web.BackOffice/Install/CreateUnattendedUserNotificationHandler.cs index df25dda78a..3990f42aa7 100644 --- a/src/Umbraco.Web.Common/Install/CreateUnattendedUserNotificationHandler.cs +++ b/src/Umbraco.Web.BackOffice/Install/CreateUnattendedUserNotificationHandler.cs @@ -12,7 +12,7 @@ using Umbraco.Cms.Core.Security; using Umbraco.Cms.Core.Services; using Umbraco.Extensions; -namespace Umbraco.Cms.Web.Common.Install +namespace Umbraco.Cms.Web.BackOffice.Install { public class CreateUnattendedUserNotificationHandler : INotificationAsyncHandler { diff --git a/src/Umbraco.Web.Common/Install/InstallApiController.cs b/src/Umbraco.Web.BackOffice/Install/InstallApiController.cs similarity index 89% rename from src/Umbraco.Web.Common/Install/InstallApiController.cs rename to src/Umbraco.Web.BackOffice/Install/InstallApiController.cs index 6efe11c2a0..bbdd183d90 100644 --- a/src/Umbraco.Web.Common/Install/InstallApiController.cs +++ b/src/Umbraco.Web.BackOffice/Install/InstallApiController.cs @@ -6,18 +6,20 @@ using System.Threading.Tasks; using Microsoft.AspNetCore.Mvc; using Microsoft.Extensions.Logging; using Newtonsoft.Json.Linq; -using Umbraco.Cms.Core.Hosting; using Umbraco.Cms.Core.Install; using Umbraco.Cms.Core.Install.Models; using Umbraco.Cms.Core.Logging; +using Umbraco.Cms.Core.Security; +using Umbraco.Cms.Core.Services; using Umbraco.Cms.Infrastructure.Install; using Umbraco.Cms.Infrastructure.Migrations.Install; +using Umbraco.Cms.Web.BackOffice.Security; using Umbraco.Cms.Web.Common.ActionsResults; using Umbraco.Cms.Web.Common.Attributes; using Umbraco.Cms.Web.Common.Filters; using Umbraco.Extensions; -namespace Umbraco.Cms.Web.Common.Install +namespace Umbraco.Cms.Web.BackOffice.Install { [UmbracoApiController] [AngularJsonOnlyConfiguration] @@ -27,20 +29,31 @@ namespace Umbraco.Cms.Web.Common.Install { private readonly DatabaseBuilder _databaseBuilder; private readonly InstallStatusTracker _installStatusTracker; - private readonly IUmbracoApplicationLifetime _umbracoApplicationLifetime; + private readonly IRuntime _runtime; + private readonly IBackOfficeUserManager _backOfficeUserManager; + private readonly IBackOfficeSignInManager _backOfficeSignInManager; private readonly InstallStepCollection _installSteps; private readonly ILogger _logger; private readonly IProfilingLogger _proflog; - public InstallApiController(DatabaseBuilder databaseBuilder, IProfilingLogger proflog, ILogger logger, - InstallHelper installHelper, InstallStepCollection installSteps, InstallStatusTracker installStatusTracker, - IUmbracoApplicationLifetime umbracoApplicationLifetime) + public InstallApiController( + DatabaseBuilder databaseBuilder, + IProfilingLogger proflog, + ILogger logger, + InstallHelper installHelper, + InstallStepCollection installSteps, + InstallStatusTracker installStatusTracker, + IRuntime runtime, + IBackOfficeUserManager backOfficeUserManager, + IBackOfficeSignInManager backOfficeSignInManager) { _databaseBuilder = databaseBuilder ?? throw new ArgumentNullException(nameof(databaseBuilder)); _proflog = proflog ?? throw new ArgumentNullException(nameof(proflog)); _installSteps = installSteps; _installStatusTracker = installStatusTracker; - _umbracoApplicationLifetime = umbracoApplicationLifetime; + _runtime = runtime; + _backOfficeUserManager = backOfficeUserManager; + _backOfficeSignInManager = backOfficeSignInManager; InstallHelper = installHelper; _logger = logger; } @@ -86,7 +99,13 @@ namespace Umbraco.Cms.Web.Common.Install [HttpPost] public async Task CompleteInstall() { - _umbracoApplicationLifetime.Restart(); + + await _runtime.StopAsync(_runtime.CancellationToken); + await _runtime.StartAsync(_runtime.CancellationToken); + + var identityUser = await _backOfficeUserManager.FindByIdAsync(Core.Constants.Security.SuperUserIdAsString); + _backOfficeSignInManager.SignInAsync(identityUser, false); + return NoContent(); } diff --git a/src/Umbraco.Web.Common/Install/InstallAreaRoutes.cs b/src/Umbraco.Web.BackOffice/Install/InstallAreaRoutes.cs similarity index 98% rename from src/Umbraco.Web.Common/Install/InstallAreaRoutes.cs rename to src/Umbraco.Web.BackOffice/Install/InstallAreaRoutes.cs index 6a89d3b770..28871db452 100644 --- a/src/Umbraco.Web.Common/Install/InstallAreaRoutes.cs +++ b/src/Umbraco.Web.BackOffice/Install/InstallAreaRoutes.cs @@ -7,7 +7,7 @@ using Umbraco.Cms.Core.Services; using Umbraco.Cms.Web.Common.Routing; using Umbraco.Extensions; -namespace Umbraco.Cms.Web.Common.Install +namespace Umbraco.Cms.Web.BackOffice.Install { public class InstallAreaRoutes : IAreaRoutes diff --git a/src/Umbraco.Web.Common/Install/InstallAuthorizeAttribute.cs b/src/Umbraco.Web.BackOffice/Install/InstallAuthorizeAttribute.cs similarity index 97% rename from src/Umbraco.Web.Common/Install/InstallAuthorizeAttribute.cs rename to src/Umbraco.Web.BackOffice/Install/InstallAuthorizeAttribute.cs index 71482db274..ee55f22888 100644 --- a/src/Umbraco.Web.Common/Install/InstallAuthorizeAttribute.cs +++ b/src/Umbraco.Web.BackOffice/Install/InstallAuthorizeAttribute.cs @@ -5,7 +5,7 @@ using Microsoft.Extensions.Logging; using Umbraco.Cms.Core; using Umbraco.Cms.Core.Services; -namespace Umbraco.Cms.Web.Common.Install +namespace Umbraco.Cms.Web.BackOffice.Install { /// /// Ensures authorization occurs for the installer if it has already completed. diff --git a/src/Umbraco.Web.Common/Install/InstallController.cs b/src/Umbraco.Web.BackOffice/Install/InstallController.cs similarity index 99% rename from src/Umbraco.Web.Common/Install/InstallController.cs rename to src/Umbraco.Web.BackOffice/Install/InstallController.cs index 4bee2c0a0f..721e6718fe 100644 --- a/src/Umbraco.Web.Common/Install/InstallController.cs +++ b/src/Umbraco.Web.BackOffice/Install/InstallController.cs @@ -13,10 +13,10 @@ using Umbraco.Cms.Core.Security; using Umbraco.Cms.Core.Services; using Umbraco.Cms.Core.WebAssets; using Umbraco.Cms.Infrastructure.Install; -using Umbraco.Extensions; using Umbraco.Cms.Web.Common.Filters; +using Umbraco.Extensions; -namespace Umbraco.Cms.Web.Common.Install +namespace Umbraco.Cms.Web.BackOffice.Install { /// diff --git a/src/Umbraco.Web.BackOffice/Routing/BackOfficeAreaRoutes.cs b/src/Umbraco.Web.BackOffice/Routing/BackOfficeAreaRoutes.cs index 2a83b45fd5..13d57ccc43 100644 --- a/src/Umbraco.Web.BackOffice/Routing/BackOfficeAreaRoutes.cs +++ b/src/Umbraco.Web.BackOffice/Routing/BackOfficeAreaRoutes.cs @@ -47,12 +47,7 @@ namespace Umbraco.Cms.Web.BackOffice.Routing switch (_runtimeState.Level) { case RuntimeLevel.Install: - // a new install so we don't route the back office - break; case RuntimeLevel.Upgrade: - // for upgrades we only need to route the back office and auth controllers - MapMinimalBackOffice(endpoints); - break; case RuntimeLevel.Run: MapMinimalBackOffice(endpoints); diff --git a/src/Umbraco.Web.BackOffice/Routing/PreviewRoutes.cs b/src/Umbraco.Web.BackOffice/Routing/PreviewRoutes.cs index a207a727fb..bda08d0d87 100644 --- a/src/Umbraco.Web.BackOffice/Routing/PreviewRoutes.cs +++ b/src/Umbraco.Web.BackOffice/Routing/PreviewRoutes.cs @@ -35,9 +35,7 @@ namespace Umbraco.Cms.Web.BackOffice.Routing switch (_runtimeState.Level) { case RuntimeLevel.Install: - break; case RuntimeLevel.Upgrade: - break; case RuntimeLevel.Run: endpoints.MapHub(GetPreviewHubRoute()); endpoints.MapUmbracoRoute(_umbracoPathSegment, Constants.Web.Mvc.BackOfficeArea, null); diff --git a/src/Umbraco.Web.Common/DependencyInjection/UmbracoBuilderExtensions.cs b/src/Umbraco.Web.Common/DependencyInjection/UmbracoBuilderExtensions.cs index 58ea578ec3..02f6a04ef9 100644 --- a/src/Umbraco.Web.Common/DependencyInjection/UmbracoBuilderExtensions.cs +++ b/src/Umbraco.Web.Common/DependencyInjection/UmbracoBuilderExtensions.cs @@ -48,7 +48,6 @@ using Umbraco.Cms.Web.Common.ApplicationModels; using Umbraco.Cms.Web.Common.AspNetCore; using Umbraco.Cms.Web.Common.Controllers; using Umbraco.Cms.Web.Common.DependencyInjection; -using Umbraco.Cms.Web.Common.Install; using Umbraco.Cms.Web.Common.Localization; using Umbraco.Cms.Web.Common.Macros; using Umbraco.Cms.Web.Common.Middleware; @@ -298,8 +297,6 @@ namespace Umbraco.Extensions builder.WithCollectionBuilder() .Add(umbracoApiControllerTypes); - builder.Services.AddUnique(); - builder.Services.AddUnique(); builder.Services.AddUnique(); builder.Services.AddUnique(); @@ -320,11 +317,6 @@ namespace Umbraco.Extensions return builder; } - public static IUmbracoBuilder AddUnattedInstallCreateUser(this IUmbracoBuilder builder) - { - builder.AddNotificationAsyncHandler(); - return builder; - } // TODO: Does this need to exist and/or be public? public static IUmbracoBuilder AddWebServer(this IUmbracoBuilder builder) diff --git a/src/Umbraco.Web.Common/Extensions/LinkGeneratorExtensions.cs b/src/Umbraco.Web.Common/Extensions/LinkGeneratorExtensions.cs index e0a6802a8d..c30eefd918 100644 --- a/src/Umbraco.Web.Common/Extensions/LinkGeneratorExtensions.cs +++ b/src/Umbraco.Web.Common/Extensions/LinkGeneratorExtensions.cs @@ -10,7 +10,6 @@ using Umbraco.Cms.Core; using Umbraco.Cms.Core.Hosting; using Umbraco.Cms.Core.Web.Mvc; using Umbraco.Cms.Web.Common.Controllers; -using Umbraco.Cms.Web.Common.Install; namespace Umbraco.Extensions { @@ -39,21 +38,6 @@ namespace Umbraco.Extensions return linkGenerator.GetPathByAction("Default", ControllerExtensions.GetControllerName(backOfficeControllerType), values: new { area = Cms.Core.Constants.Web.Mvc.BackOfficeApiArea }); } - /// - /// Returns the URL for the installer - /// - public static string GetInstallerUrl(this LinkGenerator linkGenerator) - => linkGenerator.GetPathByAction(nameof(InstallController.Index), ControllerExtensions.GetControllerName(), new { area = Cms.Core.Constants.Web.Mvc.InstallArea }); - - /// - /// Returns the URL for the installer api - /// - public static string GetInstallerApiUrl(this LinkGenerator linkGenerator) - => linkGenerator.GetPathByAction( - nameof(InstallApiController.GetSetup), - ControllerExtensions.GetControllerName(), - new { area = Cms.Core.Constants.Web.Mvc.InstallArea }).TrimEnd(nameof(InstallApiController.GetSetup)); - /// /// Return the Url for a Web Api service /// diff --git a/src/Umbraco.Web.Common/Middleware/UmbracoRequestMiddleware.cs b/src/Umbraco.Web.Common/Middleware/UmbracoRequestMiddleware.cs index c8a7abf727..fe0029bd80 100644 --- a/src/Umbraco.Web.Common/Middleware/UmbracoRequestMiddleware.cs +++ b/src/Umbraco.Web.Common/Middleware/UmbracoRequestMiddleware.cs @@ -17,6 +17,7 @@ using Umbraco.Cms.Core.Notifications; using Umbraco.Cms.Core.Routing; using Umbraco.Cms.Core.Scoping; using Umbraco.Cms.Core.Security; +using Umbraco.Cms.Core.Services; using Umbraco.Cms.Core.Web; using Umbraco.Cms.Infrastructure.PublishedCache; using Umbraco.Cms.Infrastructure.WebAssets; @@ -48,6 +49,7 @@ namespace Umbraco.Cms.Web.Common.Middleware private readonly IHostingEnvironment _hostingEnvironment; private readonly UmbracoRequestPaths _umbracoRequestPaths; private readonly BackOfficeWebAssets _backOfficeWebAssets; + private readonly IRuntimeState _runtimeState; private readonly SmidgeOptions _smidgeOptions; private readonly WebProfiler _profiler; @@ -74,7 +76,8 @@ namespace Umbraco.Cms.Web.Common.Middleware IHostingEnvironment hostingEnvironment, UmbracoRequestPaths umbracoRequestPaths, BackOfficeWebAssets backOfficeWebAssets, - IOptions smidgeOptions) + IOptions smidgeOptions, + IRuntimeState runtimeState) { _logger = logger; _umbracoContextFactory = umbracoContextFactory; @@ -84,6 +87,7 @@ namespace Umbraco.Cms.Web.Common.Middleware _hostingEnvironment = hostingEnvironment; _umbracoRequestPaths = umbracoRequestPaths; _backOfficeWebAssets = backOfficeWebAssets; + _runtimeState = runtimeState; _smidgeOptions = smidgeOptions.Value; _profiler = profiler as WebProfiler; // Ignore if not a WebProfiler } @@ -102,7 +106,7 @@ namespace Umbraco.Cms.Web.Common.Middleware // Profiling start needs to be one of the first things that happens. // Also MiniProfiler.Current becomes null if it is handled by the event aggregator due to async/await - _profiler?.UmbracoApplicationBeginRequest(context); + _profiler?.UmbracoApplicationBeginRequest(context, _runtimeState.Level); EnsureContentCacheInitialized(); @@ -162,7 +166,7 @@ namespace Umbraco.Cms.Web.Common.Middleware // Profiling end needs to be last of the first things that happens. // Also MiniProfiler.Current becomes null if it is handled by the event aggregator due to async/await - _profiler?.UmbracoApplicationEndRequest(context); + _profiler?.UmbracoApplicationEndRequest(context, _runtimeState.Level); } /// @@ -213,7 +217,7 @@ namespace Umbraco.Cms.Web.Common.Middleware } // ensure this is disposed by DI at the end of the request - IHttpScopeReference httpScopeReference = request.HttpContext.RequestServices.GetRequiredService(); + IHttpScopeReference httpScopeReference = request.HttpContext.RequestServices.GetRequiredService(); httpScopeReference.Register(); } diff --git a/src/Umbraco.Web.Common/Profiler/InitializeWebProfiling.cs b/src/Umbraco.Web.Common/Profiler/InitializeWebProfiling.cs index 755282bcf4..45901314a6 100644 --- a/src/Umbraco.Web.Common/Profiler/InitializeWebProfiling.cs +++ b/src/Umbraco.Web.Common/Profiler/InitializeWebProfiling.cs @@ -2,6 +2,7 @@ // See LICENSE for more details. using Microsoft.Extensions.Logging; +using Umbraco.Cms.Core; using Umbraco.Cms.Core.Events; using Umbraco.Cms.Core.Logging; using Umbraco.Cms.Core.Notifications; @@ -44,7 +45,7 @@ namespace Umbraco.Cms.Web.Common.Profiler /// public void Handle(UmbracoApplicationStartingNotification notification) { - if (_profile) + if (_profile && notification.RuntimeLevel == RuntimeLevel.Run) { // Stop the profiling of the booting process _profiler.StopBoot(); diff --git a/src/Umbraco.Web.Common/Profiler/WebProfiler.cs b/src/Umbraco.Web.Common/Profiler/WebProfiler.cs index 899373f35e..caf0b2fae0 100644 --- a/src/Umbraco.Web.Common/Profiler/WebProfiler.cs +++ b/src/Umbraco.Web.Common/Profiler/WebProfiler.cs @@ -3,7 +3,9 @@ using System.Linq; using System.Threading; using Microsoft.AspNetCore.Http; using StackExchange.Profiling; +using Umbraco.Cms.Core; using Umbraco.Cms.Core.Logging; +using Umbraco.Cms.Core.Services; using Umbraco.Extensions; namespace Umbraco.Cms.Web.Common.Profiler @@ -38,30 +40,46 @@ namespace Umbraco.Cms.Web.Common.Profiler public void Stop(bool discardResults = false) => MiniProfilerContext.Value?.Stop(discardResults); - public void UmbracoApplicationBeginRequest(HttpContext context) + public void UmbracoApplicationBeginRequest(HttpContext context, RuntimeLevel runtimeLevel) { + if (runtimeLevel < RuntimeLevel.Run) + { + return; + } + if (ShouldProfile(context.Request)) + { Start(); + } } - public void UmbracoApplicationEndRequest(HttpContext context) + public void UmbracoApplicationEndRequest(HttpContext context, RuntimeLevel runtimeLevel) { + if (runtimeLevel < RuntimeLevel.Run) + { + return; + } + if (ShouldProfile(context.Request)) { Stop(); - // if this is the first request, append the startup profiler - var first = Interlocked.Exchange(ref _first, 1) == 0; - if (first) + if (MiniProfilerContext.Value is not null) { + // if this is the first request, append the startup profiler + var first = Interlocked.Exchange(ref _first, 1) == 0; + if (first) + { - var startupDuration = _startupProfiler.Root.DurationMilliseconds.GetValueOrDefault(); - MiniProfilerContext.Value.DurationMilliseconds += startupDuration; - MiniProfilerContext.Value.GetTimingHierarchy().First().DurationMilliseconds += startupDuration; - MiniProfilerContext.Value.Root.AddChild(_startupProfiler.Root); + var startupDuration = _startupProfiler.Root.DurationMilliseconds.GetValueOrDefault(); + MiniProfilerContext.Value.DurationMilliseconds += startupDuration; + MiniProfilerContext.Value.GetTimingHierarchy().First().DurationMilliseconds += startupDuration; + MiniProfilerContext.Value.Root.AddChild(_startupProfiler.Root); - _startupProfiler = null; + _startupProfiler = null; + } } + } } diff --git a/src/Umbraco.Web.UI.Client/src/installer/installer.service.js b/src/Umbraco.Web.UI.Client/src/installer/installer.service.js index 2f0ae4b8cf..27b1381f02 100644 --- a/src/Umbraco.Web.UI.Client/src/installer/installer.service.js +++ b/src/Umbraco.Web.UI.Client/src/installer/installer.service.js @@ -30,7 +30,7 @@ angular.module("umbraco.install").factory('installerService', function ($rootSco "At least 4 people have the Umbraco logo tattooed on them", "'Umbraco' is the Danish name for an allen key", "Umbraco has been around since 2005, that's a looong time in IT", - "More than 700 people from all over the world meet each year in Denmark in May for our annual conference CodeGarden", + "More than 700 people from all over the world meet each year in Denmark in May for our annual conference CodeGarden", "While you are installing Umbraco someone else on the other side of the planet is probably doing it too", "You can extend Umbraco without modifying the source code using either JavaScript or C#", "Umbraco has been installed in more than 198 countries" @@ -47,7 +47,7 @@ angular.module("umbraco.install").factory('installerService', function ($rootSco } return null; } - /* Returns the description for the given step name */ + /* Returns the description for the given step name */ function getDescriptionForStepName(steps, name) { var found = _.find(steps, function(i) { return i.name == name; @@ -166,8 +166,8 @@ angular.module("umbraco.install").factory('installerService', function ($rootSco service.status.current = step; }, - /** - Finds the next step containing a view. If one is found it stores it as the current step + /** + Finds the next step containing a view. If one is found it stores it as the current step and retreives the step information and returns it, otherwise returns null . */ findNextStep : function(){ @@ -315,12 +315,10 @@ angular.module("umbraco.install").factory('installerService', function ($rootSco clearInterval(factTimer); } - $timeout(function(){ - window.location.href = Umbraco.Sys.ServerVariables.umbracoBaseUrl; - }, 5000); + window.location.href = Umbraco.Sys.ServerVariables.umbracoBaseUrl; }, handleErrorResponse); - - + + } }; @@ -354,6 +352,6 @@ angular.module("umbraco.install").factory('installerService', function ($rootSco service.switchToConfiguration(); } - + return service; });