Fix UmbracoContext issue (with a TODO)
This commit is contained in:
@@ -1,4 +1,5 @@
|
||||
using Umbraco.Core.Services;
|
||||
using Umbraco.Core;
|
||||
using Umbraco.Core.Services;
|
||||
|
||||
namespace Umbraco.Web.PublishedCache
|
||||
{
|
||||
@@ -8,17 +9,20 @@ namespace Umbraco.Web.PublishedCache
|
||||
public class DefaultCultureAccessor : IDefaultCultureAccessor
|
||||
{
|
||||
private readonly ILocalizationService _localizationService;
|
||||
private readonly RuntimeLevel _runtimeLevel;
|
||||
|
||||
/// <summary>
|
||||
/// Initializes a new instance of the <see cref="DefaultCultureAccessor"/> class.
|
||||
/// </summary>
|
||||
/// <param name="localizationService"></param>
|
||||
public DefaultCultureAccessor(ILocalizationService localizationService)
|
||||
public DefaultCultureAccessor(ILocalizationService localizationService, IRuntimeState runtimeState)
|
||||
{
|
||||
_localizationService = localizationService;
|
||||
_runtimeLevel = runtimeState.Level;
|
||||
}
|
||||
|
||||
/// <inheritdoc />
|
||||
public string DefaultCulture => _localizationService.GetDefaultLanguageIsoCode() ?? ""; // fast
|
||||
public string DefaultCulture => _runtimeLevel == RuntimeLevel.Run
|
||||
? _localizationService.GetDefaultLanguageIsoCode() ?? "" // fast
|
||||
: "en-US"; // default for install and upgrade, when the service is n/a
|
||||
}
|
||||
}
|
||||
|
||||
@@ -95,6 +95,7 @@ namespace Umbraco.Web
|
||||
|
||||
// ok, process
|
||||
|
||||
// TODO: should we move this to after we've ensured we are processing a routable page?
|
||||
// ensure there's an UmbracoContext registered for the current request
|
||||
// registers the context reference so its disposed at end of request
|
||||
var umbracoContextReference = _umbracoContextFactory.EnsureUmbracoContext(httpContext);
|
||||
|
||||
Reference in New Issue
Block a user