Bug fixes for macros

This commit is contained in:
Bjarke Berg
2020-02-10 19:59:47 +01:00
parent e94921b384
commit 4d15c8c044
7 changed files with 41 additions and 34 deletions

View File

@@ -7,7 +7,7 @@ using Umbraco.Core.Serialization;
namespace Umbraco.Web.Cache
{
public sealed class MacroCacheRefresher : JsonCacheRefresherBase<MacroCacheRefresher, MacroCacheRefresher.JsonPayload>
public sealed class MacroCacheRefresher : PayloadCacheRefresherBase<MacroCacheRefresher, MacroCacheRefresher.JsonPayload>
{
public MacroCacheRefresher(AppCaches appCaches, IJsonSerializer jsonSerializer)
: base(appCaches, jsonSerializer)

View File

@@ -6,7 +6,7 @@ using Umbraco.Core.Serialization;
namespace Umbraco.Web.Cache
{
public sealed class MemberGroupCacheRefresher : JsonCacheRefresherBase<MemberGroupCacheRefresher, MemberGroupCacheRefresher.JsonPayload>
public sealed class MemberGroupCacheRefresher : PayloadCacheRefresherBase<MemberGroupCacheRefresher, MemberGroupCacheRefresher.JsonPayload>
{
public MemberGroupCacheRefresher(AppCaches appCaches, IJsonSerializer jsonSerializer)
: base(appCaches, jsonSerializer)

View File

@@ -11,8 +11,13 @@ using System.Web.SessionState;
using Umbraco.Web.Models.ContentEditing;
using Umbraco.Web.Mvc;
using Umbraco.Core;
using Umbraco.Core.Cache;
using Umbraco.Core.Configuration;
using Umbraco.Core.Logging;
using Umbraco.Core.Mapping;
using Umbraco.Core.Models;
using Umbraco.Core.Models.PublishedContent;
using Umbraco.Core.Persistence;
using Umbraco.Core.Services;
using Umbraco.Core.Strings;
@@ -30,18 +35,39 @@ namespace Umbraco.Web.Editors
public class MacroRenderingController : UmbracoAuthorizedJsonController, IRequiresSessionState
{
private readonly IMacroService _macroService;
private readonly IContentService _contentService;
private readonly IShortStringHelper _shortStringHelper;
private readonly IUmbracoComponentRenderer _componentRenderer;
private readonly IVariationContextAccessor _variationContextAccessor;
public MacroRenderingController(IUmbracoComponentRenderer componentRenderer, IVariationContextAccessor variationContextAccessor, IMacroService macroService, IContentService contentService, IShortStringHelper shortStringHelper)
public MacroRenderingController(
IGlobalSettings globalSettings,
IUmbracoContextAccessor umbracoContextAccessor,
ISqlContext sqlContext,
ServiceContext services,
AppCaches appCaches,
IProfilingLogger logger,
IRuntimeState runtimeState,
UmbracoHelper umbracoHelper,
IShortStringHelper shortStringHelper,
UmbracoMapper umbracoMapper,
IUmbracoComponentRenderer componentRenderer,
IVariationContextAccessor variationContextAccessor,
IMacroService macroService)
: base(
globalSettings,
umbracoContextAccessor,
sqlContext,
services,
appCaches,
logger,
runtimeState,
umbracoHelper,
shortStringHelper,
umbracoMapper)
{
_componentRenderer = componentRenderer;
_variationContextAccessor = variationContextAccessor;
_macroService = macroService;
_contentService = contentService;
_shortStringHelper = shortStringHelper;
}
/// <summary>
@@ -162,7 +188,7 @@ namespace Umbraco.Web.Editors
var macroName = model.Filename.TrimEnd(".cshtml");
var macro = new Macro(_shortStringHelper)
var macro = new Macro(ShortStringHelper)
{
Alias = macroName.ToSafeAlias(ShortStringHelper),
Name = macroName,

View File

@@ -7,6 +7,7 @@ using Umbraco.Core.Mapping;
using Umbraco.Core.Persistence;
using Umbraco.Core.Services;
using Umbraco.Core.Strings;
using Umbraco.Web.Composing;
using Umbraco.Web.WebApi;
using Umbraco.Web.WebApi.Filters;
@@ -25,6 +26,7 @@ namespace Umbraco.Web.Editors
{
protected UmbracoAuthorizedJsonController()
{
ShortStringHelper = Current.ShortStringHelper;
}
protected UmbracoAuthorizedJsonController(IGlobalSettings globalSettings, IUmbracoContextAccessor umbracoContextAccessor, ISqlContext sqlContext, ServiceContext services, AppCaches appCaches, IProfilingLogger logger, IRuntimeState runtimeState, UmbracoHelper umbracoHelper, IShortStringHelper shortStringHelper, UmbracoMapper umbracoMapper)

View File

@@ -14,13 +14,13 @@ namespace Umbraco.Web.Install.InstallSteps
PerformsAppRestart = true)]
internal class StarterKitInstallStep : InstallSetupStep<object>
{
private readonly HttpContextBase _httContext;
private readonly IHttpContextAccessor _httContextAccessor;
private readonly IUmbracoContextAccessor _umbracoContextAccessor;
private readonly IPackagingService _packagingService;
public StarterKitInstallStep(HttpContextBase httContext, IUmbracoContextAccessor umbracoContextAccessor, IPackagingService packagingService)
public StarterKitInstallStep(IHttpContextAccessor httContextAccessor, IUmbracoContextAccessor umbracoContextAccessor, IPackagingService packagingService)
{
_httContext = httContext;
_httContextAccessor = httContextAccessor;
_umbracoContextAccessor = umbracoContextAccessor;
_packagingService = packagingService;
}
@@ -34,7 +34,7 @@ namespace Umbraco.Web.Install.InstallSteps
InstallBusinessLogic(packageId);
UmbracoApplication.Restart(_httContext);
UmbracoApplication.Restart(_httContextAccessor.HttpContext);
return Task.FromResult<InstallSetupResult>(null);
}

View File

@@ -30,7 +30,6 @@ namespace Umbraco.Web.Routing
private CultureInfo _culture;
private IPublishedContent _publishedContent;
private IPublishedContent _initialPublishedContent; // found by finders before 404, redirects, etc
private PublishedContentHashtableConverter _umbracoPage; // legacy
/// <summary>
/// Initializes a new instance of the <see cref="IPublishedRequest"/> class.
@@ -480,23 +479,5 @@ namespace Umbraco.Web.Routing
public Dictionary<string, string> Headers { get; set; } = new Dictionary<string, string>();
#endregion
#region Legacy
// for legacy/webforms/macro code -
// TODO: get rid of it eventually
public PublishedContentHashtableConverter LegacyContentHashTable
{
get
{
if (_umbracoPage == null)
throw new InvalidOperationException("The UmbracoPage object has not been initialized yet.");
return _umbracoPage;
}
set => _umbracoPage = value;
}
#endregion
}
}

View File

@@ -165,6 +165,7 @@
<Compile Include="Logging\WebProfilerComposer.cs" />
<Compile Include="Logging\WebProfilerProvider.cs" />
<Compile Include="Macros\IMacroRenderer.cs" />
<Compile Include="Macros\PublishedContentHashtableConverter.cs" />
<Compile Include="Migrations\PostMigrations\PublishedSnapshotRebuilder.cs" />
<Compile Include="Models\ContentEditing\UserInvite.cs" />
<Compile Include="Models\Identity\BackOfficeIdentityUser.cs" />
@@ -697,9 +698,6 @@
<Compile Include="Properties\AssemblyInfo.cs">
<SubType>Code</SubType>
</Compile>
<Compile Include="Macros\PublishedContentHashtableConverter.cs">
<SubType>Code</SubType>
</Compile>
<Compile Include="UmbracoApplication.cs" />
<Compile Include="UmbracoInjectedModule.cs" />
<Compile Include="UriUtility.cs" />