From 9dcc901395cbb74f05d6ec004be0dbdd37f213a3 Mon Sep 17 00:00:00 2001 From: Mole Date: Wed, 10 Feb 2021 13:55:16 +0100 Subject: [PATCH] Ensure that SqlCeSupport is still enabled after changing the namespace --- .../InstallSteps/DatabaseConfigureStep.cs | 2 +- .../Migrations/Install/DatabaseBuilder.cs | 20 +++++++++---------- .../Persistence/DatabaseBuilderTests.cs | 3 +-- .../UmbracoBuilderExtensions.cs | 6 +++--- 4 files changed, 15 insertions(+), 16 deletions(-) diff --git a/src/Umbraco.Infrastructure/Install/InstallSteps/DatabaseConfigureStep.cs b/src/Umbraco.Infrastructure/Install/InstallSteps/DatabaseConfigureStep.cs index 9fb12ca40b..9d4bf57f55 100644 --- a/src/Umbraco.Infrastructure/Install/InstallSteps/DatabaseConfigureStep.cs +++ b/src/Umbraco.Infrastructure/Install/InstallSteps/DatabaseConfigureStep.cs @@ -98,7 +98,7 @@ namespace Umbraco.Web.Install.InstallSteps // NOTE: Type.GetType will only return types that are currently loaded into the appdomain. In this case // that is ok because we know if this is availalbe we will have manually loaded it into the appdomain. // Else we'd have to use Assembly.LoadFrom and need to know the DLL location here which we don't need to do. - return !(Type.GetType("Umbraco.Persistence.SqlCe.SqlCeSyntaxProvider, Umbraco.Persistence.SqlCe") is null); + return !(Type.GetType("Umbraco.Cms.Persistence.SqlCe.SqlCeSyntaxProvider, Umbraco.Persistence.SqlCe") is null); } public override string View => ShouldDisplayView() ? base.View : ""; diff --git a/src/Umbraco.Infrastructure/Migrations/Install/DatabaseBuilder.cs b/src/Umbraco.Infrastructure/Migrations/Install/DatabaseBuilder.cs index 58de0552fe..8efb6d13b4 100644 --- a/src/Umbraco.Infrastructure/Migrations/Install/DatabaseBuilder.cs +++ b/src/Umbraco.Infrastructure/Migrations/Install/DatabaseBuilder.cs @@ -93,7 +93,7 @@ namespace Umbraco.Core.Migrations.Install else if (integratedAuth) { // has to be Sql Server - providerName = Cms.Core.Constants.DbProviderNames.SqlServer; + providerName = Constants.DbProviderNames.SqlServer; connectionString = GetIntegratedSecurityDatabaseConnectionString(server, database); } else @@ -115,7 +115,7 @@ namespace Umbraco.Core.Migrations.Install var sql = scope.Database.SqlContext.Sql() .SelectCount() .From() - .Where(x => x.Id == Cms.Core.Constants.Security.SuperUserId && x.Password == "default"); + .Where(x => x.Id == Constants.Security.SuperUserId && x.Password == "default"); var result = scope.Database.ExecuteScalar(sql); var has = result != 1; if (has == false) @@ -154,7 +154,7 @@ namespace Umbraco.Core.Migrations.Install private void ConfigureEmbeddedDatabaseConnection(IUmbracoDatabaseFactory factory) { - _configManipulator.SaveConnectionString(EmbeddedDatabaseConnectionString, Cms.Core.Constants.DbProviderNames.SqlCe); + _configManipulator.SaveConnectionString(EmbeddedDatabaseConnectionString, Constants.DbProviderNames.SqlCe); var path = _hostingEnvironment.MapPathContentRoot(Path.Combine("App_Data", "Umbraco.sdf")); if (File.Exists(path) == false) @@ -162,10 +162,10 @@ namespace Umbraco.Core.Migrations.Install // this should probably be in a "using (new SqlCeEngine)" clause but not sure // of the side effects and it's been like this for quite some time now - _dbProviderFactoryCreator.CreateDatabase(Cms.Core.Constants.DbProviderNames.SqlCe); + _dbProviderFactoryCreator.CreateDatabase(Constants.DbProviderNames.SqlCe); } - factory.Configure(EmbeddedDatabaseConnectionString, Cms.Core.Constants.DbProviderNames.SqlCe); + factory.Configure(EmbeddedDatabaseConnectionString, Constants.DbProviderNames.SqlCe); } /// @@ -175,7 +175,7 @@ namespace Umbraco.Core.Migrations.Install /// Has to be SQL Server public void ConfigureDatabaseConnection(string connectionString) { - const string providerName = Cms.Core.Constants.DbProviderNames.SqlServer; + const string providerName = Constants.DbProviderNames.SqlServer; _configManipulator.SaveConnectionString(connectionString, providerName); _databaseFactory.Configure(connectionString, providerName); @@ -209,7 +209,7 @@ namespace Umbraco.Core.Migrations.Install /// A connection string. public static string GetDatabaseConnectionString(string server, string databaseName, string user, string password, string databaseProvider, out string providerName) { - providerName = Cms.Core.Constants.DbProviderNames.SqlServer; + providerName = Constants.DbProviderNames.SqlServer; var provider = databaseProvider.ToLower(); if (provider.InvariantContains("azure")) return GetAzureConnectionString(server, databaseName, user, password); @@ -224,8 +224,8 @@ namespace Umbraco.Core.Migrations.Install public void ConfigureIntegratedSecurityDatabaseConnection(string server, string databaseName) { var connectionString = GetIntegratedSecurityDatabaseConnectionString(server, databaseName); - _configManipulator.SaveConnectionString(connectionString, Cms.Core.Constants.DbProviderNames.SqlServer); - _databaseFactory.Configure(connectionString, Cms.Core.Constants.DbProviderNames.SqlServer); + _configManipulator.SaveConnectionString(connectionString, Constants.DbProviderNames.SqlServer); + _databaseFactory.Configure(connectionString, Constants.DbProviderNames.SqlServer); } /// @@ -467,7 +467,7 @@ namespace Umbraco.Core.Migrations.Install { Message = "The database configuration failed with the following message: " + ex.Message + - $"\n Please check log file for additional information (can be found in '{Cms.Core.Constants.SystemDirectories.LogFiles}')", + $"\n Please check log file for additional information (can be found in '{Constants.SystemDirectories.LogFiles}')", Success = false, Percentage = "90" }; diff --git a/src/Umbraco.Tests.Integration/Umbraco.Infrastructure/Persistence/DatabaseBuilderTests.cs b/src/Umbraco.Tests.Integration/Umbraco.Infrastructure/Persistence/DatabaseBuilderTests.cs index e94b2bd7f6..9f0dda4563 100644 --- a/src/Umbraco.Tests.Integration/Umbraco.Infrastructure/Persistence/DatabaseBuilderTests.cs +++ b/src/Umbraco.Tests.Integration/Umbraco.Infrastructure/Persistence/DatabaseBuilderTests.cs @@ -5,19 +5,18 @@ using Microsoft.Extensions.Logging.Abstractions; using Moq; using NPoco; using NUnit.Framework; +using Umbraco.Cms.Core; using Umbraco.Cms.Core.Configuration; using Umbraco.Core.Migrations.Install; using Umbraco.Core.Persistence; using Umbraco.Tests.Common.TestHelpers; using Umbraco.Tests.Integration.Testing; using Umbraco.Tests.Testing; -using Constants = Umbraco.Cms.Core.Constants; namespace Umbraco.Tests.UnitTests.Umbraco.Infrastructure.Persistence { [TestFixture] [UmbracoTest] - public class DatabaseBuilderTests : UmbracoIntegrationTest { private IDbProviderFactoryCreator DbProviderFactoryCreator => GetRequiredService(); diff --git a/src/Umbraco.Web.Common/DependencyInjection/UmbracoBuilderExtensions.cs b/src/Umbraco.Web.Common/DependencyInjection/UmbracoBuilderExtensions.cs index 590ea3bbc5..067c55225f 100644 --- a/src/Umbraco.Web.Common/DependencyInjection/UmbracoBuilderExtensions.cs +++ b/src/Umbraco.Web.Common/DependencyInjection/UmbracoBuilderExtensions.cs @@ -315,9 +315,9 @@ namespace Umbraco.Extensions var dllPath = Path.Combine(binFolder, "Umbraco.Persistence.SqlCe.dll"); var umbSqlCeAssembly = Assembly.LoadFrom(dllPath); - var sqlCeSyntaxProviderType = umbSqlCeAssembly.GetType("Umbraco.Persistence.SqlCe.SqlCeSyntaxProvider"); - var sqlCeBulkSqlInsertProviderType = umbSqlCeAssembly.GetType("Umbraco.Persistence.SqlCe.SqlCeBulkSqlInsertProvider"); - var sqlCeEmbeddedDatabaseCreatorType = umbSqlCeAssembly.GetType("Umbraco.Persistence.SqlCe.SqlCeEmbeddedDatabaseCreator"); + var sqlCeSyntaxProviderType = umbSqlCeAssembly.GetType("Umbraco.Cms.Persistence.SqlCe.SqlCeSyntaxProvider"); + var sqlCeBulkSqlInsertProviderType = umbSqlCeAssembly.GetType("Umbraco.Cms.Persistence.SqlCe.SqlCeBulkSqlInsertProvider"); + var sqlCeEmbeddedDatabaseCreatorType = umbSqlCeAssembly.GetType("Umbraco.Cms.Persistence.SqlCe.SqlCeEmbeddedDatabaseCreator"); if (!(sqlCeSyntaxProviderType is null || sqlCeBulkSqlInsertProviderType is null || sqlCeEmbeddedDatabaseCreatorType is null)) {