From e5e077c4267511e0cf96e074ca50a8dac7d40fb6 Mon Sep 17 00:00:00 2001 From: Ronald Barendse Date: Tue, 26 Nov 2024 10:01:30 +0100 Subject: [PATCH 1/7] Remove legacy Umbraco.Web (merged from v8) --- .../Security/UmbracoApplicationUrlCheck.cs | 109 ------------------ 1 file changed, 109 deletions(-) delete mode 100644 src/Umbraco.Web/HealthCheck/Checks/Security/UmbracoApplicationUrlCheck.cs diff --git a/src/Umbraco.Web/HealthCheck/Checks/Security/UmbracoApplicationUrlCheck.cs b/src/Umbraco.Web/HealthCheck/Checks/Security/UmbracoApplicationUrlCheck.cs deleted file mode 100644 index bc14f43235..0000000000 --- a/src/Umbraco.Web/HealthCheck/Checks/Security/UmbracoApplicationUrlCheck.cs +++ /dev/null @@ -1,109 +0,0 @@ -using System; -using System.Collections.Generic; -using Umbraco.Core; -using Umbraco.Core.Configuration.UmbracoSettings; -using Umbraco.Core.IO; -using Umbraco.Core.Services; -using Umbraco.Web.HealthCheck.Checks.Config; - -namespace Umbraco.Web.HealthCheck.Checks.Security -{ - [HealthCheck( - "6708CA45-E96E-40B8-A40A-0607C1CA7F28", - "Application URL Configuration", - Description = "Checks if the Umbraco application URL is configured for your site.", - Group = "Security")] - public class UmbracoApplicationUrlCheck : HealthCheck - { - private readonly ILocalizedTextService _textService; - private readonly IRuntimeState _runtime; - private readonly IUmbracoSettingsSection _settings; - - private const string SetApplicationUrlAction = "setApplicationUrl"; - - public UmbracoApplicationUrlCheck(ILocalizedTextService textService, IRuntimeState runtime, IUmbracoSettingsSection settings) - { - _textService = textService; - _runtime = runtime; - _settings = settings; - } - - /// - /// Executes the action and returns its status - /// - /// - /// - public override HealthCheckStatus ExecuteAction(HealthCheckAction action) - { - switch (action.Alias) - { - case SetApplicationUrlAction: - return SetUmbracoApplicationUrl(); - default: - throw new InvalidOperationException("UmbracoApplicationUrlCheck action requested is either not executable or does not exist"); - } - } - - public override IEnumerable GetStatus() - { - //return the statuses - return new[] { CheckUmbracoApplicationUrl() }; - } - - private HealthCheckStatus CheckUmbracoApplicationUrl() - { - var url = _settings.WebRouting.UmbracoApplicationUrl; - - string resultMessage; - StatusResultType resultType; - var actions = new List(); - - if (url.IsNullOrWhiteSpace()) - { - resultMessage = _textService.Localize("healthcheck", "umbracoApplicationUrlCheckResultFalse"); - resultType = StatusResultType.Warning; - - actions.Add(new HealthCheckAction(SetApplicationUrlAction, Id) - { - Name = _textService.Localize("healthcheck", "umbracoApplicationUrlConfigureButton"), - Description = _textService.Localize("healthcheck", "umbracoApplicationUrlConfigureDescription") - }); - } - else - { - resultMessage = _textService.Localize("healthcheck", "umbracoApplicationUrlCheckResultTrue", new[] { url }); - resultType = StatusResultType.Success; - } - - return new HealthCheckStatus(resultMessage) - { - ResultType = resultType, - Actions = actions - }; - } - - private HealthCheckStatus SetUmbracoApplicationUrl() - { - var configFilePath = IOHelper.MapPath("~/config/umbracoSettings.config"); - const string xPath = "/settings/web.routing/@umbracoApplicationUrl"; - var configurationService = new ConfigurationService(configFilePath, xPath, _textService); - var urlValue = _runtime.ApplicationUrl.ToString(); - var updateConfigFile = configurationService.UpdateConfigFile(urlValue); - - if (updateConfigFile.Success) - { - return - new HealthCheckStatus(_textService.Localize("healthcheck", "umbracoApplicationUrlConfigureSuccess", new[] { urlValue })) - { - ResultType = StatusResultType.Success - }; - } - - return - new HealthCheckStatus(_textService.Localize("healthcheck", "umbracoApplicationUrlConfigureError", new[] { updateConfigFile.Result })) - { - ResultType = StatusResultType.Error - }; - } - } -} From d5a674271ce08554dc5dd89f0d4911fec3897110 Mon Sep 17 00:00:00 2001 From: Jesper Mayntzhusen <79840720+jemayn@users.noreply.github.com> Date: Thu, 28 Nov 2024 13:01:17 +0100 Subject: [PATCH 2/7] Update README.txt Fixed broken link --- templates/UmbracoExtension/README.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/templates/UmbracoExtension/README.txt b/templates/UmbracoExtension/README.txt index 7beee9137e..e887480f11 100644 --- a/templates/UmbracoExtension/README.txt +++ b/templates/UmbracoExtension/README.txt @@ -35,4 +35,4 @@ * Use VSCode as the editor of choice as it has good tooling support for TypeScript and it will recommend a VSCode Extension for good Lit WebComponent completions == Other Resources == -* Umbraco Docs - https://docs.umbraco.com/umbraco-cms/customizing/extend-and-customize-editing-experience +* Umbraco Docs - https://docs.umbraco.com/umbraco-cms/customizing/overview From d0799b1b9d80b70866b7046593915a9a0f4fab65 Mon Sep 17 00:00:00 2001 From: mjpraxis <47383499+mjpraxis@users.noreply.github.com> Date: Wed, 27 Nov 2024 14:12:53 +0100 Subject: [PATCH 3/7] Change meta tag "apple-mobile-web-app-capable" with "mobile-web-app-capable" --- .../umbraco/UmbracoBackOffice/Index.cshtml | 2 +- src/Umbraco.Cms.StaticAssets/umbraco/UmbracoLogin/Index.cshtml | 2 +- src/Umbraco.Web.UI.Login/index.html | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/src/Umbraco.Cms.StaticAssets/umbraco/UmbracoBackOffice/Index.cshtml b/src/Umbraco.Cms.StaticAssets/umbraco/UmbracoBackOffice/Index.cshtml index 16fb9c48e6..a7235c0b29 100644 --- a/src/Umbraco.Cms.StaticAssets/umbraco/UmbracoBackOffice/Index.cshtml +++ b/src/Umbraco.Cms.StaticAssets/umbraco/UmbracoBackOffice/Index.cshtml @@ -28,7 +28,7 @@ - + Umbraco diff --git a/src/Umbraco.Cms.StaticAssets/umbraco/UmbracoLogin/Index.cshtml b/src/Umbraco.Cms.StaticAssets/umbraco/UmbracoLogin/Index.cshtml index 856796cd25..4268b73125 100644 --- a/src/Umbraco.Cms.StaticAssets/umbraco/UmbracoLogin/Index.cshtml +++ b/src/Umbraco.Cms.StaticAssets/umbraco/UmbracoLogin/Index.cshtml @@ -40,7 +40,7 @@ - + Umbraco diff --git a/src/Umbraco.Web.UI.Login/index.html b/src/Umbraco.Web.UI.Login/index.html index bef2e18ce0..d859365864 100644 --- a/src/Umbraco.Web.UI.Login/index.html +++ b/src/Umbraco.Web.UI.Login/index.html @@ -5,7 +5,7 @@ - + Umbraco From 09575599ad540e9678af3bbca0af6286ee82f9f6 Mon Sep 17 00:00:00 2001 From: Jeroen Breuer Date: Fri, 3 Jan 2025 17:59:50 +0100 Subject: [PATCH 4/7] Fix Umbraco.Tests.Common warnings. (#17172) * Fix async warning. * Fix MediaFileManager warning. * Fix TypeLoader warning. * Fix CodeBase warning. * Fix ContentTypeEditingBuilder warning. * Fix _containerKey warning. * Fix _key warning. * Fix issues due to merge with contrib --------- Co-authored-by: Laura Neto <12862535+lauraneto@users.noreply.github.com> --- .../Builders/ContentTypeEditingBuilder.cs | 2 +- tests/Umbraco.Tests.Common/TestHelperBase.cs | 5 ++--- tests/Umbraco.Tests.Common/TestLastChanceFinder.cs | 2 +- 3 files changed, 4 insertions(+), 5 deletions(-) diff --git a/tests/Umbraco.Tests.Common/Builders/ContentTypeEditingBuilder.cs b/tests/Umbraco.Tests.Common/Builders/ContentTypeEditingBuilder.cs index c9cdc41552..f34decd0c2 100644 --- a/tests/Umbraco.Tests.Common/Builders/ContentTypeEditingBuilder.cs +++ b/tests/Umbraco.Tests.Common/Builders/ContentTypeEditingBuilder.cs @@ -192,7 +192,7 @@ public class ContentTypeEditingBuilder : ContentTypeEditingBaseBuilder(), loggerFactory.CreateLogger(), Mock.Of(), - Mock.Of(), - Options.Create(new ContentSettings())); + Mock.Of()); var databaseFactory = new Mock(); var database = new Mock(); var sqlContext = new Mock(); @@ -207,7 +206,7 @@ public abstract class TestHelperBase throw new ArgumentException("relativePath must start with '~/'", nameof(relativePath)); } - var codeBase = typeof(TestHelperBase).Assembly.CodeBase; + var codeBase = typeof(TestHelperBase).Assembly.Location; var uri = new Uri(codeBase); var path = uri.LocalPath; var bin = Path.GetDirectoryName(path); diff --git a/tests/Umbraco.Tests.Common/TestLastChanceFinder.cs b/tests/Umbraco.Tests.Common/TestLastChanceFinder.cs index 3b00e20981..85c8f7b97f 100644 --- a/tests/Umbraco.Tests.Common/TestLastChanceFinder.cs +++ b/tests/Umbraco.Tests.Common/TestLastChanceFinder.cs @@ -8,5 +8,5 @@ namespace Umbraco.Cms.Tests.Common; public class TestLastChanceFinder : IContentLastChanceFinder { - public async Task TryFindContent(IPublishedRequestBuilder frequest) => false; + public Task TryFindContent(IPublishedRequestBuilder frequest) => Task.FromResult(false); } From ba58c6323c3944b371e9357ccc4019c396b7a44e Mon Sep 17 00:00:00 2001 From: Sebastiaan Janssen Date: Tue, 7 Jan 2025 10:25:41 +0200 Subject: [PATCH 5/7] Don't add a blanket rule to allow synchronous IO, should not be necessary for the new management API (#17886) * Don't add a blanket rule to allow synchronous IO, should not be necessary for the new management API * Add obsolete warning --- .../DependencyInjection/UmbracoBuilderExtensions.cs | 13 +------------ 1 file changed, 1 insertion(+), 12 deletions(-) diff --git a/src/Umbraco.Web.Common/DependencyInjection/UmbracoBuilderExtensions.cs b/src/Umbraco.Web.Common/DependencyInjection/UmbracoBuilderExtensions.cs index 33f7a9d4e2..4451320947 100644 --- a/src/Umbraco.Web.Common/DependencyInjection/UmbracoBuilderExtensions.cs +++ b/src/Umbraco.Web.Common/DependencyInjection/UmbracoBuilderExtensions.cs @@ -326,20 +326,9 @@ public static partial class UmbracoBuilderExtensions return builder; } - // TODO: Does this need to exist and/or be public? + [Obsolete("This is not necessary any more. This will be removed in v17")] public static IUmbracoBuilder AddWebServer(this IUmbracoBuilder builder) { - // TODO: We need to figure out why this is needed and fix those endpoints to not need them, we don't want to change global things - // If using Kestrel: https://stackoverflow.com/a/55196057 - builder.Services.Configure(options => - { - options.AllowSynchronousIO = true; - }); - builder.Services.Configure(options => - { - options.AllowSynchronousIO = true; - }); - return builder; } From c4021e27e5f01a9a4311393a275082cbd3d9fa8a Mon Sep 17 00:00:00 2001 From: Sebastiaan Janssen Date: Tue, 14 Jan 2025 01:32:43 +0100 Subject: [PATCH 6/7] Fixing problem on Linux where `dotnet run` fails because we try to set an IIS config (#17903) * Don't add a blanket rule to allow synchronous IO, should not be necessary for the new management API * Add obsolete warning * Catch errors while adding global rule to allow synchronous IO, which fails on non-windows machines * Some updates based on PR feedback --- .../UmbracoBuilderExtensions.cs | 31 ++++++++++++++++++- 1 file changed, 30 insertions(+), 1 deletion(-) diff --git a/src/Umbraco.Web.Common/DependencyInjection/UmbracoBuilderExtensions.cs b/src/Umbraco.Web.Common/DependencyInjection/UmbracoBuilderExtensions.cs index 4451320947..2070b59bb7 100644 --- a/src/Umbraco.Web.Common/DependencyInjection/UmbracoBuilderExtensions.cs +++ b/src/Umbraco.Web.Common/DependencyInjection/UmbracoBuilderExtensions.cs @@ -1,6 +1,7 @@ using System.Data.Common; using System.Net.Http.Headers; using System.Reflection; +using System.Runtime.CompilerServices; using Microsoft.AspNetCore.Builder; using Microsoft.AspNetCore.DataProtection.Infrastructure; using Microsoft.AspNetCore.Hosting; @@ -326,12 +327,40 @@ public static partial class UmbracoBuilderExtensions return builder; } - [Obsolete("This is not necessary any more. This will be removed in v17")] + [Obsolete("This is not necessary any more. This will be removed in v16")] public static IUmbracoBuilder AddWebServer(this IUmbracoBuilder builder) { + builder.Services.Configure(options => + { + options.AllowSynchronousIO = true; + }); + + try + { + // See https://github.com/umbraco/Umbraco-CMS/pull/17886. This is a workaround for non-windows machines + // they won't have IIS available and trying to set this option will throw an exception. + // + // We're deferring this call to a method because if we just try to set the options here, we still get a + // TypeLoadException on non-windows machines. + // This workaround came from this comment: https://stackoverflow.com/a/3346975 + AllowSynchronousIOForIIS(builder); + } + catch (TypeLoadException) + { + // Ignoring this exception because it's expected on non-windows machines + } return builder; } + // Prevents the compiler from inlining the method + [MethodImpl(MethodImplOptions.NoInlining)] + private static void AllowSynchronousIOForIIS(IUmbracoBuilder builder) => + builder.Services.Configure( + options => + { + options.AllowSynchronousIO = true; + }); + private static IProfiler GetWebProfiler(IConfiguration config, IHttpContextAccessor httpContextAccessor) { var isDebug = config.GetValue($"{Constants.Configuration.ConfigHosting}:Debug"); From fd9c1a0e9c9a1d851e8ec75bc866e3e9a38a56e7 Mon Sep 17 00:00:00 2001 From: Justin Neville <67802060+justin-nevitech@users.noreply.github.com> Date: Tue, 14 Jan 2025 12:32:09 +0000 Subject: [PATCH 7/7] Fixes issue with the IVirtualPageController not setting PublishedRequest content via FindContent (#15121) * Fixes issue https://github.com/umbraco/Umbraco-CMS/issues/12834 * Re-worked based on feedback * Use dependency injection * Only call new constructor --------- Co-authored-by: Nikolaj Geisle <70372949+Zeegaan@users.noreply.github.com> --- .../Routing/UmbracoVirtualPageRoute.cs | 27 +++++++++++++++++-- 1 file changed, 25 insertions(+), 2 deletions(-) diff --git a/src/Umbraco.Web.Common/Routing/UmbracoVirtualPageRoute.cs b/src/Umbraco.Web.Common/Routing/UmbracoVirtualPageRoute.cs index 9813cf3212..f8bbd8ec76 100644 --- a/src/Umbraco.Web.Common/Routing/UmbracoVirtualPageRoute.cs +++ b/src/Umbraco.Web.Common/Routing/UmbracoVirtualPageRoute.cs @@ -5,8 +5,10 @@ using Microsoft.AspNetCore.Mvc.Controllers; using Microsoft.AspNetCore.Mvc.Filters; using Microsoft.AspNetCore.Routing; using Microsoft.Extensions.DependencyInjection; +using Umbraco.Cms.Core.DependencyInjection; using Umbraco.Cms.Core.Models.PublishedContent; using Umbraco.Cms.Core.Routing; +using Umbraco.Cms.Core.Web; using Umbraco.Cms.Web.Common.Controllers; using Umbraco.Cms.Web.Common.Extensions; @@ -21,6 +23,7 @@ public class UmbracoVirtualPageRoute : IUmbracoVirtualPageRoute private readonly LinkParser _linkParser; private readonly UriUtility _uriUtility; private readonly IPublishedRouter _publishedRouter; + private readonly IUmbracoContextAccessor _umbracoContextAccessor; /// /// Constructor. @@ -29,16 +32,29 @@ public class UmbracoVirtualPageRoute : IUmbracoVirtualPageRoute /// The link parser. /// The Uri utility. /// The published router. + /// The umbraco context accessor. public UmbracoVirtualPageRoute( EndpointDataSource endpointDataSource, LinkParser linkParser, UriUtility uriUtility, - IPublishedRouter publishedRouter) + IPublishedRouter publishedRouter, + IUmbracoContextAccessor umbracoContextAccessor) { _endpointDataSource = endpointDataSource; _linkParser = linkParser; _uriUtility = uriUtility; _publishedRouter = publishedRouter; + _umbracoContextAccessor = umbracoContextAccessor; + } + + [Obsolete("Please use constructor that takes an IUmbracoContextAccessor instead, scheduled for removal in v17")] + public UmbracoVirtualPageRoute( + EndpointDataSource endpointDataSource, + LinkParser linkParser, + UriUtility uriUtility, + IPublishedRouter publishedRouter) + : this(endpointDataSource, linkParser, uriUtility, publishedRouter, StaticServiceProvider.Instance.GetRequiredService()) + { } /// @@ -157,7 +173,8 @@ public class UmbracoVirtualPageRoute : IUmbracoVirtualPageRoute requestBuilder.SetPublishedContent(publishedContent); _publishedRouter.RouteDomain(requestBuilder); - return requestBuilder.Build(); + // Ensure the culture and domain is set correctly for the published request + return await _publishedRouter.RouteRequestAsync(requestBuilder, new RouteRequestOptions(Core.Routing.RouteDirection.Inbound)); } /// @@ -171,6 +188,12 @@ public class UmbracoVirtualPageRoute : IUmbracoVirtualPageRoute { IPublishedRequest publishedRequest = await CreatePublishedRequest(httpContext, publishedContent); + // Ensure the published request is set to the UmbracoContext + if (_umbracoContextAccessor.TryGetUmbracoContext(out IUmbracoContext? umbracoContext)) + { + umbracoContext.PublishedRequest = publishedRequest; + } + var umbracoRouteValues = new UmbracoRouteValues( publishedRequest, controllerActionDescriptor);