Merge branch 'release/10.0.1' into v10/dev

# Conflicts:
#	src/Umbraco.Core/Actions/ActionAssignDomain.cs
#	src/Umbraco.Core/Configuration/Models/ModelsBuilderSettings.cs
#	src/Umbraco.Core/Models/RelationItem.cs
#	src/Umbraco.Core/Scoping/ICoreScope.cs
#	src/Umbraco.Infrastructure/DependencyInjection/UmbracoBuilder.CoreServices.cs
#	src/Umbraco.Infrastructure/HostedServices/ReportSiteTask.cs
#	src/Umbraco.Infrastructure/Logging/MessageTemplates.cs
#	src/Umbraco.Infrastructure/Persistence/DbProviderFactoryCreator.cs
#	src/Umbraco.Infrastructure/Runtime/FileSystemMainDomLock.cs
#	src/Umbraco.Infrastructure/Scoping/ScopeProvider.cs
#	src/Umbraco.Web.BackOffice/Filters/OutgoingEditorModelEventAttribute.cs
#	src/Umbraco.Web.BackOffice/Mapping/ContentMapDefinition.cs
#	tests/Umbraco.Tests.Integration/TestServerTest/UmbracoTestServerTestBase.cs
#	tests/Umbraco.Tests.UnitTests/Umbraco.Core/Components/ComponentTests.cs
#	tests/Umbraco.Tests.UnitTests/Umbraco.Core/Scoping/ScopedNotificationPublisherTests.cs
#	tests/Umbraco.Tests.UnitTests/Umbraco.Infrastructure/Scoping/ScopeUnitTests.cs
#	version.json
This commit is contained in:
Zeegaan
2022-06-30 09:48:24 +02:00
14 changed files with 67 additions and 42 deletions

View File

@@ -39,7 +39,7 @@ public class SqlServerDistributedLockingMechanism : IDistributedLockingMechanism
/// <inheritdoc />
public bool Enabled => _connectionStrings.CurrentValue.IsConnectionStringConfigured() &&
_connectionStrings.CurrentValue.ProviderName == Constants.ProviderName;
string.Equals(_connectionStrings.CurrentValue.ProviderName,Constants.ProviderName, StringComparison.InvariantCultureIgnoreCase);
/// <inheritdoc />
public IDistributedLock ReadLock(int lockId, TimeSpan? obtainLockTimeout = null)

View File

@@ -8,5 +8,8 @@ public static class Constants
/// <summary>
/// SQLite provider name.
/// </summary>
public const string ProviderName = "Microsoft.Data.SQLite";
public const string ProviderName = "Microsoft.Data.Sqlite";
[Obsolete("This will be removed in Umbraco 12. Use Constants.ProviderName instead")]
public const string ProviderNameLegacy = "Microsoft.Data.SQLite";
}

View File

@@ -35,7 +35,7 @@ public class SqliteDistributedLockingMechanism : IDistributedLockingMechanism
/// <inheritdoc />
public bool Enabled => _connectionStrings.CurrentValue.IsConnectionStringConfigured() &&
_connectionStrings.CurrentValue.ProviderName == Constants.ProviderName;
string.Equals(_connectionStrings.CurrentValue.ProviderName, Constants.ProviderName, StringComparison.InvariantCultureIgnoreCase);
// With journal_mode=wal we can always read a snapshot.
public IDistributedLock ReadLock(int lockId, TimeSpan? obtainLockTimeout = null)

View File

@@ -46,11 +46,14 @@ public static class UmbracoBuilderExtensions
DbProviderFactories.UnregisterFactory(Constants.ProviderName);
DbProviderFactories.RegisterFactory(Constants.ProviderName, SqliteFactory.Instance);
DbProviderFactories.UnregisterFactory(Constants.ProviderNameLegacy);
DbProviderFactories.RegisterFactory(Constants.ProviderNameLegacy, Microsoft.Data.Sqlite.SqliteFactory.Instance);
// Prevent accidental creation of SQLite database files
builder.Services.PostConfigureAll<ConnectionStrings>(options =>
{
// Skip empty connection string and other providers
if (!options.IsConnectionStringConfigured() || options.ProviderName != Constants.ProviderName)
if (!options.IsConnectionStringConfigured() || (options.ProviderName != Constants.ProviderName && options.ProviderName != Constants.ProviderNameLegacy))
{
return;
}

View File

@@ -50,11 +50,11 @@ public class ModelsBuilderSettings
}
return _flagOutOfDateModels;
}
set =>_flagOutOfDateModels = value;
}
set => _flagOutOfDateModels = value;
}
/// <summary>
/// Gets or sets a value for the models directory.

View File

@@ -103,6 +103,8 @@ public static partial class UmbracoBuilderExtensions
builder.Services.AddSingleton<Core.Scoping.IScopeProvider>(f => f.GetRequiredService<ScopeProvider>());
builder.Services.AddSingleton<IAmbientScopeStack, AmbientScopeStack>();
builder.Services.AddSingleton<IAmbientScopeStack, AmbientScopeStack>();
builder.Services.AddSingleton<IScopeAccessor>(f => f.GetRequiredService<IAmbientScopeStack>());
builder.Services.AddSingleton<IAmbientScopeContextStack, AmbientScopeContextStack>();

View File

@@ -85,7 +85,8 @@ public class ReportSiteTask : RecurringHostedServiceBase
using (var request = new HttpRequestMessage(HttpMethod.Post, "installs/"))
{
request.Content = new StringContent(JsonConvert.SerializeObject(telemetryReportData), Encoding.UTF8, "application/json");
request.Content = new StringContent(JsonConvert.SerializeObject(telemetryReportData), Encoding.UTF8,
"application/json");
// Make a HTTP Post to telemetry service
// https://telemetry.umbraco.com/installs/

View File

@@ -27,7 +27,7 @@ public static class DatabaseProviderMetadataExtensions
/// <c>true</c> if a database can be created for the specified provider name; otherwise, <c>false</c>.
/// </returns>
public static bool CanForceCreateDatabase(this IEnumerable<IDatabaseProviderMetadata> databaseProviderMetadata, string? providerName)
=> databaseProviderMetadata.FirstOrDefault(x => x.ProviderName == providerName)?.ForceCreateDatabase == true;
=> databaseProviderMetadata.FirstOrDefault(x => string.Equals(x.ProviderName, providerName, StringComparison.InvariantCultureIgnoreCase))?.ForceCreateDatabase == true;
/// <summary>
/// Generates the connection string.

View File

@@ -40,10 +40,10 @@ public class DbProviderFactoryCreator : IDbProviderFactoryCreator
{
_getFactory = getFactory;
_providerSpecificInterceptors = providerSpecificInterceptors;
_databaseCreators = databaseCreators.ToDictionary(x => x.ProviderName);
_syntaxProviders = syntaxProviders.ToDictionary(x => x.ProviderName);
_bulkSqlInsertProviders = bulkSqlInsertProviders.ToDictionary(x => x.ProviderName);
_providerSpecificMapperFactories = providerSpecificMapperFactories.ToDictionary(x => x.ProviderName);
_databaseCreators = databaseCreators.ToDictionary(x => x.ProviderName, StringComparer.InvariantCultureIgnoreCase);
_syntaxProviders = syntaxProviders.ToDictionary(x => x.ProviderName, StringComparer.InvariantCultureIgnoreCase);
_bulkSqlInsertProviders = bulkSqlInsertProviders.ToDictionary(x => x.ProviderName, StringComparer.InvariantCultureIgnoreCase);
_providerSpecificMapperFactories = providerSpecificMapperFactories.ToDictionary(x => x.ProviderName, StringComparer.InvariantCultureIgnoreCase);
}
public DbProviderFactory? CreateFactory(string? providerName)
@@ -98,5 +98,5 @@ public class DbProviderFactoryCreator : IDbProviderFactoryCreator
}
public IEnumerable<IProviderSpecificInterceptor> GetProviderSpecificInterceptors(string providerName)
=> _providerSpecificInterceptors.Where(x => x.ProviderName == providerName);
=> _providerSpecificInterceptors.Where(x => x.ProviderName.Equals(providerName, StringComparison.InvariantCultureIgnoreCase));
}

View File

@@ -11,6 +11,7 @@ internal class FileSystemMainDomLock : IMainDomLock
{
private readonly CancellationTokenSource _cancellationTokenSource = new();
private readonly IHostingEnvironment _hostingEnvironment;
private readonly IHostingEnvironment _hostingEnvironment;
private readonly IOptionsMonitor<GlobalSettings> _globalSettings;
private readonly string _lockFilePath;
private readonly ILogger<FileSystemMainDomLock> _logger;

View File

@@ -10,6 +10,9 @@ using Umbraco.Cms.Core.Scoping;
using Umbraco.Cms.Infrastructure.Persistence;
using Umbraco.Cms.Web.Common.DependencyInjection;
using Umbraco.Extensions;
using Umbraco.Cms.Core.DistributedLocking;
using Umbraco.Cms.Core.Scoping;
using Umbraco.Cms.Web.Common.DependencyInjection;
using CoreDebugSettings = Umbraco.Cms.Core.Configuration.Models.CoreDebugSettings;
#if DEBUG_SCOPES

View File

@@ -27,7 +27,7 @@ internal sealed class OutgoingEditorModelEventAttribute : TypeFilterAttribute
private class OutgoingEditorModelEventFilter : IActionFilter
{
private readonly IBackOfficeSecurityAccessor _backOfficeSecurityAccessor;
private readonly IBackOfficeSecurityAccessor _backOfficeSecurityAccessor;private readonly IUmbracoMapper _mapper;
private readonly IEventAggregator _eventAggregator;
private readonly IUmbracoMapper _mapper;
private readonly IUmbracoContextAccessor _umbracoContextAccessor;
@@ -92,7 +92,8 @@ internal sealed class OutgoingEditorModelEventAttribute : TypeFilterAttribute
case ContentItemDisplay content:
_eventAggregator.Publish(new SendingContentNotification(content, umbracoContext));
break;
case ContentItemDisplayWithSchedule contentWithSchedule:
case ContentItemDisplayWithSchedule contentWithSchedule:
// This is a bit weird, since ContentItemDisplayWithSchedule was introduced later,
// the SendingContentNotification only accepts ContentItemDisplay,
// which means we have to map it to this before sending the notification.
@@ -112,27 +113,27 @@ internal sealed class OutgoingEditorModelEventAttribute : TypeFilterAttribute
_mapper.Map(display, contentWithSchedule, mapperContext => mapperContext.Items[nameof(contentWithSchedule.Variants)] = contentWithSchedule.Variants);
break;
case MediaItemDisplay media:
_eventAggregator.Publish(new SendingMediaNotification(media, umbracoContext));
break;
case MemberDisplay member:
_eventAggregator.Publish(new SendingMemberNotification(member, umbracoContext));
break;
case UserDisplay user:
_eventAggregator.Publish(new SendingUserNotification(user, umbracoContext));
break;
case IEnumerable<Tab<IDashboardSlim>> dashboards:
_eventAggregator.Publish(new SendingDashboardsNotification(dashboards, umbracoContext));
break;
case IEnumerable<ContentTypeBasic> allowedChildren:
// Changing the Enumerable will generate a new instance, so we need to update the context result with the new content
var notification = new SendingAllowedChildrenNotification(allowedChildren, umbracoContext);
_eventAggregator.Publish(notification);
context.Result = new ObjectResult(notification.Children);
break;
_eventAggregator.Publish(new SendingMediaNotification(media, umbracoContext));
break;
case MemberDisplay member:
_eventAggregator.Publish(new SendingMemberNotification(member, umbracoContext));
break;
case UserDisplay user:
_eventAggregator.Publish(new SendingUserNotification(user, umbracoContext));
break;
case IEnumerable<Tab<IDashboardSlim>> dashboards:
_eventAggregator.Publish(new SendingDashboardsNotification(dashboards, umbracoContext));
break;
case IEnumerable<ContentTypeBasic> allowedChildren:
// Changing the Enumerable will generate a new instance, so we need to update the context result with the new content
var notification = new SendingAllowedChildrenNotification(allowedChildren, umbracoContext);
_eventAggregator.Publish(notification);
context.Result = new ObjectResult(notification.Children);
break;
}
}
}
}
}
public void OnActionExecuting(ActionExecutingContext context)
{

View File

@@ -84,15 +84,25 @@ public class PublicAccessRequestHandler : IPublicAccessRequestHandler
switch (publicAccessStatus)
{
case PublicAccessStatus.NotLoggedIn:
_logger.LogDebug("EnsurePublishedContentAccess: Not logged in, redirect to login page");
routeValues = await SetPublishedContentAsOtherPageAsync(
httpContext, routeValues.PublishedRequest, publicAccessAttempt.Result!.LoginNodeId);
// redirect if this is not the login page
if (publicAccessAttempt.Result!.LoginNodeId != publishedContent.Id)
{
_logger.LogDebug("EnsurePublishedContentAccess: Not logged in, redirect to login page");
routeValues = await SetPublishedContentAsOtherPageAsync(
httpContext, routeValues.PublishedRequest, publicAccessAttempt.Result!.LoginNodeId);
}
break;
case PublicAccessStatus.AccessDenied:
_logger.LogDebug(
"EnsurePublishedContentAccess: Current member has not access, redirect to error page");
routeValues = await SetPublishedContentAsOtherPageAsync(
httpContext, routeValues.PublishedRequest, publicAccessAttempt.Result!.NoAccessNodeId);
// Redirect if this is not the access denied page
if (publicAccessAttempt.Result!.NoAccessNodeId != publishedContent.Id)
{
_logger.LogDebug(
"EnsurePublishedContentAccess: Current member has not access, redirect to error page");
routeValues = await SetPublishedContentAsOtherPageAsync(
httpContext, routeValues.PublishedRequest, publicAccessAttempt.Result!.NoAccessNodeId);
}
break;
case PublicAccessStatus.LockedOut:
_logger.LogDebug("Current member is locked out, redirect to error page");

View File

@@ -592,10 +592,11 @@ namespace Umbraco.Cms.Tests.UnitTests.Umbraco.Infrastructure.Scoping
using (var scope = scopeProvider.CreateScope())
{
Assert.AreEqual(0, scope.Depth);
Assert.AreEqual(0,scope.Depth);
}
}
[Test]
public void Depth_WhenChildScope_ReturnsDepth()
{