diff --git a/src/Umbraco.Core/Scoping/CallContext.cs b/src/Umbraco.Core/Scoping/CallContext.cs index 2937990eab..cc8bf7cc7e 100644 --- a/src/Umbraco.Core/Scoping/CallContext.cs +++ b/src/Umbraco.Core/Scoping/CallContext.cs @@ -20,7 +20,15 @@ namespace Umbraco.Core.Scoping /// The name with which to associate the new item in the call context. /// The object to store in the call context. public static void SetData(string name, T data) => _state.GetOrAdd(name, _ => new AsyncLocal()).Value = data; - + + //Replace the SetData with the following when you need to debug AsyncLocal. The args.ThreadContextChanged can be usefull + //public static void SetData(string name, T data) => _state.GetOrAdd(name, _ => new AsyncLocal(OnValueChanged)).Value = data; + // public static void OnValueChanged(AsyncLocalValueChangedArgs args) + // { + // var typeName = typeof(T).ToString(); + // Console.WriteLine($"OnValueChanged!, Type: {typeName} Prev: #{args.PreviousValue} Current: #{args.CurrentValue}"); + // } + /// /// Retrieves an object with the specified name from the . /// diff --git a/src/Umbraco.Infrastructure/Services/Implement/UserService.cs b/src/Umbraco.Infrastructure/Services/Implement/UserService.cs index 1928ea3c12..65fb235054 100644 --- a/src/Umbraco.Infrastructure/Services/Implement/UserService.cs +++ b/src/Umbraco.Infrastructure/Services/Implement/UserService.cs @@ -998,7 +998,7 @@ namespace Umbraco.Core.Services.Implement /// /// /// - public static EntityPermissionSet CalculatePermissionsForPathForUser( + internal static EntityPermissionSet CalculatePermissionsForPathForUser( EntityPermission[] groupPermissions, int[] pathIds) { @@ -1075,7 +1075,7 @@ namespace Umbraco.Core.Services.Implement /// Flag indicating if we want to include the default group permissions for each result if there are not explicit permissions set /// /// - public static EntityPermission GetPermissionsForPathForGroup( + internal static EntityPermission GetPermissionsForPathForGroup( IEnumerable pathPermissions, int[] pathIds, bool fallbackToDefaultPermissions = false) diff --git a/src/Umbraco.Tests.Integration/TestServerTest/UmbracoTestServerTestBase.cs b/src/Umbraco.Tests.Integration/TestServerTest/UmbracoTestServerTestBase.cs index 9f10ce968e..2aacd7b8fb 100644 --- a/src/Umbraco.Tests.Integration/TestServerTest/UmbracoTestServerTestBase.cs +++ b/src/Umbraco.Tests.Integration/TestServerTest/UmbracoTestServerTestBase.cs @@ -31,7 +31,7 @@ namespace Umbraco.Tests.Integration.TestServerTest public abstract class UmbracoTestServerTestBase : UmbracoIntegrationTest { [SetUp] - public override Task Setup() + public override void Setup() { InMemoryConfiguration["ConnectionStrings:" + Constants.System.UmbracoConnectionName] = null; InMemoryConfiguration["Umbraco:CMS:Hosting:Debug"] = "true"; @@ -55,8 +55,6 @@ namespace Umbraco.Tests.Integration.TestServerTest }); LinkGenerator = Factory.Services.GetRequiredService(); - - return Task.CompletedTask; } public override IHostBuilder CreateHostBuilder() diff --git a/src/Umbraco.Tests.Integration/Testing/UmbracoIntegrationTest.cs b/src/Umbraco.Tests.Integration/Testing/UmbracoIntegrationTest.cs index 1dae786d01..4448308a2e 100644 --- a/src/Umbraco.Tests.Integration/Testing/UmbracoIntegrationTest.cs +++ b/src/Umbraco.Tests.Integration/Testing/UmbracoIntegrationTest.cs @@ -46,6 +46,7 @@ namespace Umbraco.Tests.Integration.Testing [NonParallelizable] public abstract class UmbracoIntegrationTest { + public static LightInjectContainer CreateUmbracoContainer(out UmbracoServiceProviderFactory serviceProviderFactory) { var container = UmbracoServiceProviderFactory.CreateServiceContainer(); @@ -80,10 +81,10 @@ namespace Umbraco.Tests.Integration.Testing } [SetUp] - public virtual async Task Setup() + public virtual void Setup() { var hostBuilder = CreateHostBuilder(); - var host = await hostBuilder.StartAsync(); + var host = hostBuilder.StartAsync().GetAwaiter().GetResult(); Services = host.Services; var app = new ApplicationBuilder(host.Services); Configure(app); diff --git a/src/Umbraco.Web.Common/Security/BackofficeSecurity.cs b/src/Umbraco.Web.Common/Security/BackofficeSecurity.cs index 6587501be7..c16071b68a 100644 --- a/src/Umbraco.Web.Common/Security/BackofficeSecurity.cs +++ b/src/Umbraco.Web.Common/Security/BackofficeSecurity.cs @@ -66,7 +66,7 @@ namespace Umbraco.Web.Common.Security /// public Attempt GetUserId() { - var identity = _httpContextAccessor.GetRequiredHttpContext().GetCurrentIdentity(); + var identity = _httpContextAccessor.HttpContext?.GetCurrentIdentity(); return identity == null ? Attempt.Fail() : Attempt.Succeed(identity.Id); }