Merge branch 'v12/dev' into contrib
This commit is contained in:
@@ -292,7 +292,7 @@ stages:
|
||||
Linux:
|
||||
vmImage: 'ubuntu-latest'
|
||||
testDb: SqlServer
|
||||
connectionString: 'Server=localhost,1433;User Id=sa;Password=$(SA_PASSWORD);'
|
||||
connectionString: 'Server=localhost,1433;User Id=sa;Password=$(SA_PASSWORD);TrustServerCertificate=true'
|
||||
pool:
|
||||
vmImage: $(vmImage)
|
||||
variables:
|
||||
|
||||
@@ -10,6 +10,8 @@
|
||||
<ItemGroup>
|
||||
<PackageReference Include="Microsoft.AspNetCore.App" Version="2.2.8" />
|
||||
<PackageReference Include="Swashbuckle.AspNetCore" Version="6.5.0" />
|
||||
<PackageReference Include="OpenIddict.Abstractions" Version="4.3.0" />
|
||||
<PackageReference Include="OpenIddict.AspNetCore" Version="4.3.0" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<ProjectReference Include="..\Umbraco.Core\Umbraco.Core.csproj" />
|
||||
|
||||
@@ -9,6 +9,7 @@
|
||||
<PackageReference Include="Microsoft.EntityFrameworkCore.SqlServer" Version="7.0.5" />
|
||||
<PackageReference Include="Microsoft.EntityFrameworkCore.Sqlite" Version="7.0.5" />
|
||||
<PackageReference Include="Microsoft.EntityFrameworkCore.Design" Version="7.0.5" />
|
||||
<PackageReference Include="OpenIddict.EntityFrameworkCore" Version="4.3.0" />
|
||||
</ItemGroup>
|
||||
|
||||
<ItemGroup>
|
||||
|
||||
6
src/Umbraco.Core/Models/DeliveryApi/RichTextModel.cs
Normal file
6
src/Umbraco.Core/Models/DeliveryApi/RichTextModel.cs
Normal file
@@ -0,0 +1,6 @@
|
||||
namespace Umbraco.Cms.Core.Models.DeliveryApi;
|
||||
|
||||
public class RichTextModel
|
||||
{
|
||||
public required string Markup { get; set; }
|
||||
}
|
||||
@@ -204,6 +204,13 @@ public class MultiNodeTreePickerValueConverter : PropertyValueConverterBase, IDe
|
||||
IPublishedSnapshot publishedSnapshot = _publishedSnapshotAccessor.GetRequiredPublishedSnapshot();
|
||||
|
||||
var entityType = GetEntityType(propertyType);
|
||||
|
||||
if (entityType == "content")
|
||||
{
|
||||
// TODO Why do MNTP config saves "content" and not "document"?
|
||||
entityType = Constants.UdiEntityType.Document;
|
||||
}
|
||||
|
||||
GuidUdi[] entityTypeUdis = udis.Where(udi => udi.EntityType == entityType).OfType<GuidUdi>().ToArray();
|
||||
return entityType switch
|
||||
{
|
||||
|
||||
@@ -24,6 +24,7 @@ public class ExecutedMigrationPlan
|
||||
FinalState = finalState ?? throw new ArgumentNullException(nameof(finalState));
|
||||
Successful = successful;
|
||||
CompletedTransitions = completedTransitions;
|
||||
ExecutedMigrationContexts = Array.Empty<IMigrationContext>();
|
||||
}
|
||||
|
||||
public ExecutedMigrationPlan()
|
||||
@@ -59,4 +60,7 @@ public class ExecutedMigrationPlan
|
||||
/// A collection of all the succeeded transition.
|
||||
/// </summary>
|
||||
public required IReadOnlyList<MigrationPlan.Transition> CompletedTransitions { get; init; }
|
||||
|
||||
[Obsolete("This will be removed in the V13, and replaced with UmbracoPlanExecutedNotification")]
|
||||
internal IReadOnlyList<IMigrationContext> ExecutedMigrationContexts { get; init; } = Array.Empty<IMigrationContext>();
|
||||
}
|
||||
|
||||
@@ -37,4 +37,11 @@ public interface IMigrationContext
|
||||
/// Gets or sets a value indicating whether an expression is being built.
|
||||
/// </summary>
|
||||
bool BuildingExpression { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// Adds a post-migration.
|
||||
/// </summary>
|
||||
[Obsolete("This will be removed in the V13, and replaced with a RebuildCache flag on the MigrationBase")]
|
||||
void AddPostMigration<TMigration>()
|
||||
where TMigration : MigrationBase;
|
||||
}
|
||||
|
||||
@@ -8,6 +8,8 @@ namespace Umbraco.Cms.Infrastructure.Migrations;
|
||||
/// </summary>
|
||||
internal class MigrationContext : IMigrationContext
|
||||
{
|
||||
private readonly List<Type> _postMigrations = new();
|
||||
|
||||
/// <summary>
|
||||
/// Initializes a new instance of the <see cref="MigrationContext" /> class.
|
||||
/// </summary>
|
||||
@@ -18,6 +20,10 @@ internal class MigrationContext : IMigrationContext
|
||||
Logger = logger ?? throw new ArgumentNullException(nameof(logger));
|
||||
}
|
||||
|
||||
// this is only internally exposed
|
||||
[Obsolete("This will be removed in the V13, and replaced with a RebuildCache flag on the MigrationBase")]
|
||||
internal IReadOnlyList<Type> PostMigrations => _postMigrations;
|
||||
|
||||
/// <inheritdoc />
|
||||
public ILogger<IMigrationContext> Logger { get; }
|
||||
|
||||
@@ -34,4 +40,13 @@ internal class MigrationContext : IMigrationContext
|
||||
|
||||
/// <inheritdoc />
|
||||
public bool BuildingExpression { get; set; }
|
||||
|
||||
|
||||
/// <inheritdoc />
|
||||
[Obsolete("This will be removed in the V13, and replaced with a RebuildCache flag on the MigrationBase, and a UmbracoPlanExecutedNotification.")]
|
||||
public void AddPostMigration<TMigration>()
|
||||
where TMigration : MigrationBase =>
|
||||
|
||||
// just adding - will be de-duplicated when executing
|
||||
_postMigrations.Add(typeof(TMigration));
|
||||
}
|
||||
|
||||
@@ -99,6 +99,8 @@ public class MigrationPlanExecutor : IMigrationPlanExecutor
|
||||
|
||||
ExecutedMigrationPlan result = RunMigrationPlan(plan, fromState);
|
||||
|
||||
HandlePostMigrations(result);
|
||||
|
||||
// If any completed migration requires us to rebuild cache we'll do that.
|
||||
if (_rebuildCache)
|
||||
{
|
||||
@@ -108,6 +110,33 @@ public class MigrationPlanExecutor : IMigrationPlanExecutor
|
||||
return result;
|
||||
}
|
||||
|
||||
[Obsolete]
|
||||
private void HandlePostMigrations(ExecutedMigrationPlan result)
|
||||
{
|
||||
// prepare and de-duplicate post-migrations, only keeping the 1st occurence
|
||||
var executedTypes = new HashSet<Type>();
|
||||
|
||||
foreach (var executedMigrationContext in result.ExecutedMigrationContexts)
|
||||
{
|
||||
if (executedMigrationContext is MigrationContext migrationContext)
|
||||
{
|
||||
foreach (Type migrationContextPostMigration in migrationContext.PostMigrations)
|
||||
{
|
||||
if (executedTypes.Contains(migrationContextPostMigration))
|
||||
{
|
||||
continue;
|
||||
}
|
||||
|
||||
_logger.LogInformation($"PostMigration: {migrationContextPostMigration.FullName}.");
|
||||
MigrationBase postMigration = _migrationBuilder.Build(migrationContextPostMigration, executedMigrationContext);
|
||||
postMigration.Run();
|
||||
|
||||
executedTypes.Add(migrationContextPostMigration);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private ExecutedMigrationPlan RunMigrationPlan(MigrationPlan plan, string fromState)
|
||||
{
|
||||
_logger.LogInformation("Starting '{MigrationName}'...", plan.Name);
|
||||
@@ -122,6 +151,7 @@ public class MigrationPlanExecutor : IMigrationPlanExecutor
|
||||
|
||||
List<MigrationPlan.Transition> completedTransitions = new();
|
||||
|
||||
var executedMigrationContexts = new List<IMigrationContext>();
|
||||
while (transition is not null)
|
||||
{
|
||||
_logger.LogInformation("Execute {MigrationType}", transition.MigrationType.Name);
|
||||
@@ -130,11 +160,11 @@ public class MigrationPlanExecutor : IMigrationPlanExecutor
|
||||
{
|
||||
if (transition.MigrationType.IsAssignableTo(typeof(UnscopedMigrationBase)))
|
||||
{
|
||||
RunUnscopedMigration(transition.MigrationType, plan);
|
||||
executedMigrationContexts.Add(RunUnscopedMigration(transition.MigrationType, plan));
|
||||
}
|
||||
else
|
||||
{
|
||||
RunScopedMigration(transition.MigrationType, plan);
|
||||
executedMigrationContexts.Add(RunScopedMigration(transition.MigrationType, plan));
|
||||
}
|
||||
}
|
||||
catch (Exception exception)
|
||||
@@ -149,6 +179,7 @@ public class MigrationPlanExecutor : IMigrationPlanExecutor
|
||||
FinalState = transition.SourceState,
|
||||
CompletedTransitions = completedTransitions,
|
||||
Plan = plan,
|
||||
ExecutedMigrationContexts = executedMigrationContexts
|
||||
};
|
||||
}
|
||||
|
||||
@@ -197,18 +228,21 @@ public class MigrationPlanExecutor : IMigrationPlanExecutor
|
||||
FinalState = finalState,
|
||||
CompletedTransitions = completedTransitions,
|
||||
Plan = plan,
|
||||
ExecutedMigrationContexts = executedMigrationContexts
|
||||
};
|
||||
}
|
||||
|
||||
private void RunUnscopedMigration(Type migrationType, MigrationPlan plan)
|
||||
private MigrationContext RunUnscopedMigration(Type migrationType, MigrationPlan plan)
|
||||
{
|
||||
using IUmbracoDatabase database = _databaseFactory.CreateDatabase();
|
||||
var context = new MigrationContext(plan, database, _loggerFactory.CreateLogger<MigrationContext>());
|
||||
|
||||
RunMigration(migrationType, context);
|
||||
|
||||
return context;
|
||||
}
|
||||
|
||||
private void RunScopedMigration(Type migrationType, MigrationPlan plan)
|
||||
private MigrationContext RunScopedMigration(Type migrationType, MigrationPlan plan)
|
||||
{
|
||||
// We want to suppress scope (service, etc...) notifications during a migration plan
|
||||
// execution. This is because if a package that doesn't have their migration plan
|
||||
@@ -225,6 +259,8 @@ public class MigrationPlanExecutor : IMigrationPlanExecutor
|
||||
RunMigration(migrationType, context);
|
||||
|
||||
scope.Complete();
|
||||
|
||||
return context;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -22,6 +22,11 @@ public class ResetCache : MigrationBase
|
||||
|
||||
private void DeleteAllFilesInFolder(string path)
|
||||
{
|
||||
if (Directory.Exists(path) == false)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
var directoryInfo = new DirectoryInfo(path);
|
||||
|
||||
foreach (FileInfo file in directoryInfo.GetFiles())
|
||||
|
||||
@@ -82,13 +82,16 @@ public class RteMacroRenderingValueConverter : SimpleTinyMceValueConverter, IDel
|
||||
public Type GetDeliveryApiPropertyValueType(IPublishedPropertyType propertyType)
|
||||
=> _deliveryApiSettings.RichTextOutputAsJson
|
||||
? typeof(IRichTextElement)
|
||||
: typeof(string);
|
||||
: typeof(RichTextModel);
|
||||
|
||||
public object? ConvertIntermediateToDeliveryApiObject(IPublishedElement owner, IPublishedPropertyType propertyType, PropertyCacheLevel referenceCacheLevel, object? inter, bool preview)
|
||||
{
|
||||
if (_deliveryApiSettings.RichTextOutputAsJson is false)
|
||||
{
|
||||
return Convert(inter, preview) ?? string.Empty;
|
||||
return new RichTextModel
|
||||
{
|
||||
Markup = Convert(inter, preview, false) ?? string.Empty
|
||||
};
|
||||
}
|
||||
|
||||
var sourceString = inter?.ToString();
|
||||
@@ -126,7 +129,7 @@ public class RteMacroRenderingValueConverter : SimpleTinyMceValueConverter, IDel
|
||||
}
|
||||
}
|
||||
|
||||
private string? Convert(object? source, bool preview)
|
||||
private string? Convert(object? source, bool preview, bool handleMacros = true)
|
||||
{
|
||||
if (source == null)
|
||||
{
|
||||
@@ -141,7 +144,10 @@ public class RteMacroRenderingValueConverter : SimpleTinyMceValueConverter, IDel
|
||||
sourceString = _imageSourceParser.EnsureImageSources(sourceString);
|
||||
|
||||
// ensure string is parsed for macros and macros are executed correctly
|
||||
sourceString = RenderRteMacros(sourceString, preview);
|
||||
if (handleMacros)
|
||||
{
|
||||
sourceString = RenderRteMacros(sourceString, preview);
|
||||
}
|
||||
|
||||
// find and remove the rel attributes used in the Umbraco UI from img tags
|
||||
var doc = new HtmlDocument();
|
||||
|
||||
@@ -93,7 +93,9 @@ public class MultiNodeTreePickerValueConverterTests : PropertyValueConverterTest
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void MultiNodeTreePickerValueConverter_RendersContentProperties()
|
||||
[TestCase(Constants.UdiEntityType.Document)]
|
||||
[TestCase("content")]
|
||||
public void MultiNodeTreePickerValueConverter_RendersContentProperties(string entityType)
|
||||
{
|
||||
var content = new Mock<IPublishedContent>();
|
||||
|
||||
@@ -112,7 +114,7 @@ public class MultiNodeTreePickerValueConverterTests : PropertyValueConverterTest
|
||||
.Setup(pcc => pcc.GetById(key))
|
||||
.Returns(content.Object);
|
||||
|
||||
var publishedDataType = MultiNodePickerPublishedDataType(false, Constants.UdiEntityType.Document);
|
||||
var publishedDataType = MultiNodePickerPublishedDataType(false, entityType);
|
||||
var publishedPropertyType = new Mock<IPublishedPropertyType>();
|
||||
publishedPropertyType.SetupGet(p => p.DataType).Returns(publishedDataType);
|
||||
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
{
|
||||
"$schema": "https://raw.githubusercontent.com/dotnet/Nerdbank.GitVersioning/master/src/NerdBank.GitVersioning/version.schema.json",
|
||||
"version": "12.0.0-rc",
|
||||
"version": "12.0.0-rc1",
|
||||
"assemblyVersion": {
|
||||
"precision": "build"
|
||||
},
|
||||
|
||||
Reference in New Issue
Block a user