Merge remote-tracking branch 'origin/v13/dev' into v14/dev

This commit is contained in:
Bjarke Berg
2023-12-20 15:17:37 +01:00
6 changed files with 93 additions and 13 deletions

View File

@@ -57,7 +57,9 @@ public static partial class UmbracoBuilderExtensions
builder.Services.AddUnique<IDeliveryApiContentIndexFieldDefinitionBuilder, DeliveryApiContentIndexFieldDefinitionBuilder>();
builder.Services.AddUnique<IDeliveryApiContentIndexHelper, DeliveryApiContentIndexHelper>();
builder.Services.AddSingleton<IDeliveryApiIndexingHandler, DeliveryApiIndexingHandler>();
builder.Services.AddSingleton<ExamineIndexRebuilder>();
builder.Services.AddSingleton<ExamineIndexRebuilder>(); //TODO remove in Umbraco 15. Only the interface should be in the service provider
builder.Services.AddUnique<IDeliveryApiCompositeIdHandler, DeliveryApiCompositeIdHandler>();
builder.AddNotificationHandler<ContentCacheRefresherNotification, ContentIndexingNotificationHandler>();

View File

@@ -10,6 +10,7 @@ using Umbraco.Cms.Infrastructure.HostedServices;
namespace Umbraco.Cms.Infrastructure.Examine;
[Obsolete("This will be removed in Umbraco 15. Use IIndexRebuilder instead.")] // Main reason for this is to remove it form the service container. Maybe even make this internal
public class ExamineIndexRebuilder : IIndexRebuilder
{
private readonly IBackgroundTaskQueue _backgroundTaskQueue;

View File

@@ -24,17 +24,38 @@ public sealed class RebuildOnStartupHandler : INotificationHandler<UmbracoReques
private static bool _isReady;
private static bool _isReadSet;
private static object? _isReadyLock;
private readonly ExamineIndexRebuilder _backgroundIndexRebuilder;
private readonly IRuntimeState _runtimeState;
private readonly ISyncBootStateAccessor _syncBootStateAccessor;
private readonly IIndexRebuilder _indexRebuilder;
[Obsolete("Use non-obsolete constructor. This is scheduled for removal in Umbraco 15.")]
public RebuildOnStartupHandler(
ISyncBootStateAccessor syncBootStateAccessor,
ExamineIndexRebuilder backgroundIndexRebuilder,
IRuntimeState runtimeState)
: this(syncBootStateAccessor, (IIndexRebuilder) backgroundIndexRebuilder, runtimeState)
{
}
[Obsolete("Use non-obsolete constructor. This is scheduled for removal in Umbraco 15.")]
public RebuildOnStartupHandler(
ISyncBootStateAccessor syncBootStateAccessor,
ExamineIndexRebuilder backgroundIndexRebuilder,
IIndexRebuilder indexRebuilder,
IRuntimeState runtimeState)
: this(syncBootStateAccessor, indexRebuilder, runtimeState)
{
}
public RebuildOnStartupHandler(
ISyncBootStateAccessor syncBootStateAccessor,
IIndexRebuilder indexRebuilder,
IRuntimeState runtimeState)
{
_syncBootStateAccessor = syncBootStateAccessor;
_backgroundIndexRebuilder = backgroundIndexRebuilder;
_indexRebuilder = indexRebuilder;
_runtimeState = runtimeState;
}
@@ -58,7 +79,7 @@ public sealed class RebuildOnStartupHandler : INotificationHandler<UmbracoReques
SyncBootState bootState = _syncBootStateAccessor.GetSyncBootState();
// if it's not a cold boot, only rebuild empty ones
_backgroundIndexRebuilder.RebuildIndexes(
_indexRebuilder.RebuildIndexes(
bootState != SyncBootState.ColdBoot,
TimeSpan.FromMinutes(1));

View File

@@ -2,7 +2,7 @@
using NPoco;
using Umbraco.Cms.Core;
using Umbraco.Cms.Infrastructure.Persistence;
using Umbraco.Cms.Infrastructure.Persistence.Dtos;
using Umbraco.Cms.Infrastructure.Persistence.DatabaseAnnotations;
using Umbraco.Extensions;
namespace Umbraco.Cms.Infrastructure.Migrations.Upgrade.V_13_0_0;
@@ -21,18 +21,18 @@ public class ChangeLogStatusCode : MigrationBase
}
Sql<ISqlContext> fetchQuery = Database.SqlContext.Sql()
.Select<WebhookLogDto>()
.From<WebhookLogDto>();
.Select<WebhookLogDtoOld>()
.From<WebhookLogDtoOld>();
// Use a custom SQL query to prevent selecting explicit columns (sortOrder doesn't exist yet)
List<WebhookLogDto> webhookLogDtos = Database.Fetch<WebhookLogDto>(fetchQuery);
List<WebhookLogDtoOld> webhookLogDtos = Database.Fetch<WebhookLogDtoOld>(fetchQuery);
Sql<ISqlContext> deleteQuery = Database.SqlContext.Sql()
.Delete<WebhookLogDto>();
.Delete<WebhookLogDtoOld>();
Database.Execute(deleteQuery);
foreach (WebhookLogDto webhookLogDto in webhookLogDtos)
foreach (WebhookLogDtoOld webhookLogDto in webhookLogDtos)
{
if (Enum.TryParse(webhookLogDto.StatusCode, out HttpStatusCode statusCode))
{
@@ -42,4 +42,62 @@ public class ChangeLogStatusCode : MigrationBase
Database.InsertBatch(webhookLogDtos);
}
[TableName(Constants.DatabaseSchema.Tables.WebhookLog)]
[PrimaryKey("id")]
[ExplicitColumns]
private class WebhookLogDtoOld
{
[Column("id")]
[PrimaryKeyColumn(AutoIncrement = true)]
public int Id { get; set; }
[Column("webhookKey")] public Guid WebhookKey { get; set; }
[Column(Name = "key")]
[NullSetting(NullSetting = NullSettings.NotNull)]
public Guid Key { get; set; }
[Column(Name = "statusCode")]
[NullSetting(NullSetting = NullSettings.NotNull)]
public string StatusCode { get; set; } = string.Empty;
[Column(Name = "date")]
[Index(IndexTypes.NonClustered, Name = "IX_" + Constants.DatabaseSchema.Tables.WebhookLog + "_date")]
[NullSetting(NullSetting = NullSettings.NotNull)]
public DateTime Date { get; set; }
[Column(Name = "url")]
[SpecialDbType(SpecialDbTypes.NVARCHARMAX)]
[NullSetting(NullSetting = NullSettings.NotNull)]
public string Url { get; set; } = string.Empty;
[Column(Name = "eventAlias")]
[NullSetting(NullSetting = NullSettings.NotNull)]
public string EventAlias { get; set; } = string.Empty;
[Column(Name = "retryCount")]
[NullSetting(NullSetting = NullSettings.NotNull)]
public int RetryCount { get; set; }
[Column(Name = "requestHeaders")]
[SpecialDbType(SpecialDbTypes.NVARCHARMAX)]
[NullSetting(NullSetting = NullSettings.NotNull)]
public string RequestHeaders { get; set; } = string.Empty;
[Column(Name = "requestBody")]
[SpecialDbType(SpecialDbTypes.NVARCHARMAX)]
[NullSetting(NullSetting = NullSettings.NotNull)]
public string RequestBody { get; set; } = string.Empty;
[Column(Name = "responseHeaders")]
[SpecialDbType(SpecialDbTypes.NVARCHARMAX)]
[NullSetting(NullSetting = NullSettings.NotNull)]
public string ResponseHeaders { get; set; } = string.Empty;
[Column(Name = "responseBody")]
[SpecialDbType(SpecialDbTypes.NVARCHARMAX)]
[NullSetting(NullSetting = NullSettings.NotNull)]
public string ResponseBody { get; set; } = string.Empty;
}
}

View File

@@ -18,7 +18,6 @@ namespace Umbraco.Cms.Web.BackOffice.Controllers;
/// Backoffice controller supporting the dashboard for language administration.
/// </summary>
[PluginController(Constants.Web.Mvc.BackOfficeApiArea)]
[Authorize(Policy = AuthorizationPolicies.SectionAccessSettings)]
public class LanguageController : UmbracoAuthorizedJsonController
{
private readonly ILocalizationService _localizationService;
@@ -44,7 +43,6 @@ public class LanguageController : UmbracoAuthorizedJsonController
/// </summary>
/// <returns></returns>
[HttpGet]
[Authorize(Policy = AuthorizationPolicies.SectionAccessContent)]
public IEnumerable<Language>? GetAllLanguages()
{
IEnumerable<ILanguage> allLanguages = _localizationService.GetAllLanguages();

View File

@@ -46,7 +46,7 @@ public static class UmbracoBuilderExtensions
builder.Services.AddUnique(Mock.Of<IUmbracoBootPermissionChecker>());
builder.Services.AddUnique(testHelper.MainDom);
builder.Services.AddUnique<ExamineIndexRebuilder, TestBackgroundIndexRebuilder>();
builder.Services.AddUnique<IIndexRebuilder, TestBackgroundIndexRebuilder>();
builder.Services.AddUnique(factory => Mock.Of<IRuntimeMinifier>());
// we don't want persisted nucache files in tests