diff --git a/src/Umbraco.Configuration/Models/HealthChecksSettingsSettings.cs b/src/Umbraco.Configuration/Models/HealthChecksSettingsSettings.cs index 1d73051ec8..1e3751b6aa 100644 --- a/src/Umbraco.Configuration/Models/HealthChecksSettingsSettings.cs +++ b/src/Umbraco.Configuration/Models/HealthChecksSettingsSettings.cs @@ -55,7 +55,7 @@ namespace Umbraco.Configuration.Models public IReadOnlyDictionary NotificationMethods => _configurationSection .GetSection("NotificationMethods") .GetChildren() - .ToDictionary(x => x.Key, x => (INotificationMethod) new NotificationMethod(x.Key, x)); + .ToDictionary(x => x.Key, x => (INotificationMethod) new NotificationMethod(x.Key, x), StringComparer.InvariantCultureIgnoreCase); public IEnumerable DisabledChecks => _configurationSection .GetSection("DisabledChecks").GetChildren().Select( @@ -87,7 +87,7 @@ namespace Umbraco.Configuration.Models public IReadOnlyDictionary Settings => _configurationSection .GetSection("Settings").GetChildren().ToDictionary(x => x.Key, - x => (INotificationMethodSettings) new NotificationMethodSettings(x.Key, x.Value)); + x => (INotificationMethodSettings) new NotificationMethodSettings(x.Key, x.Value), StringComparer.InvariantCultureIgnoreCase); } private class NotificationMethodSettings : INotificationMethodSettings diff --git a/src/Umbraco.Core/Configuration/IGlobalSettings.cs b/src/Umbraco.Core/Configuration/IGlobalSettings.cs index 434aef6e68..bf963bcec7 100644 --- a/src/Umbraco.Core/Configuration/IGlobalSettings.cs +++ b/src/Umbraco.Core/Configuration/IGlobalSettings.cs @@ -20,11 +20,6 @@ /// The reserved paths. string ReservedPaths { get; } - /// - /// Gets or sets the configuration status. This will return the version number of the currently installed umbraco instance. - /// - string ConfigurationStatus { get; set; } - /// /// Gets the time out in minutes. /// diff --git a/src/Umbraco.Core/Configuration/IUmbracoVersion.cs b/src/Umbraco.Core/Configuration/IUmbracoVersion.cs index 1bdce0ec7c..665979189d 100644 --- a/src/Umbraco.Core/Configuration/IUmbracoVersion.cs +++ b/src/Umbraco.Core/Configuration/IUmbracoVersion.cs @@ -42,15 +42,5 @@ namespace Umbraco.Core.Configuration /// SemVersion SemanticVersion { get; } - /// - /// Gets the "local" version of the site. - /// - /// - /// Three things have a version, really: the executing code, the database model, - /// and the site/files. The database model version is entirely managed via migrations, - /// and changes during an upgrade. The executing code version changes when new code is - /// deployed. The site/files version changes during an upgrade. - /// - SemVersion LocalVersion { get; } } } diff --git a/src/Umbraco.Core/Configuration/UmbracoVersion.cs b/src/Umbraco.Core/Configuration/UmbracoVersion.cs index 35154a9f50..0ddac4a8bd 100644 --- a/src/Umbraco.Core/Configuration/UmbracoVersion.cs +++ b/src/Umbraco.Core/Configuration/UmbracoVersion.cs @@ -73,23 +73,5 @@ namespace Umbraco.Core.Configuration /// It is the full version of Umbraco, including comments. /// public SemVersion SemanticVersion { get; } - - /// - /// Gets the "local" version of the site. - /// - /// - /// Three things have a version, really: the executing code, the database model, - /// and the site/files. The database model version is entirely managed via migrations, - /// and changes during an upgrade. The executing code version changes when new code is - /// deployed. The site/files version changes during an upgrade. - /// - public SemVersion LocalVersion - { - get - { - var value = _globalSettings.ConfigurationStatus; - return value.IsNullOrWhiteSpace() ? null : SemVersion.TryParse(value, out var semver) ? semver : null; - } - } } } diff --git a/src/Umbraco.Core/Install/InstallSteps/UpgradeStep.cs b/src/Umbraco.Core/Install/InstallSteps/UpgradeStep.cs index 3264bb152c..4920e09d65 100644 --- a/src/Umbraco.Core/Install/InstallSteps/UpgradeStep.cs +++ b/src/Umbraco.Core/Install/InstallSteps/UpgradeStep.cs @@ -28,13 +28,7 @@ namespace Umbraco.Web.Install.InstallSteps { get { - // TODO: if UmbracoVersion.Local is null? - // it means that there is a database but the web.config version is cleared - // that was a "normal" way to force the upgrader to execute, and we would detect the current - // version via the DB like DatabaseSchemaResult.DetermineInstalledVersion - magic, do we really - // need this now? - var currentVersion = (_umbracoVersion.LocalVersion ?? new Semver.SemVersion(0)).ToString(); - + //TODO this will always compare the same version now var newVersion = _umbracoVersion.SemanticVersion.ToString(); string FormatGuidState(string value) @@ -48,6 +42,7 @@ namespace Umbraco.Web.Install.InstallSteps var currentState = FormatGuidState(_runtimeState.CurrentMigrationState); var newState = FormatGuidState(_runtimeState.FinalMigrationState); + var currentVersion = _umbracoVersion.Current; var reportUrl = $"https://our.umbraco.com/contribute/releases/compare?from={currentVersion}&to={newVersion}¬es=1"; diff --git a/src/Umbraco.Infrastructure/Intall/InstallHelper.cs b/src/Umbraco.Infrastructure/Intall/InstallHelper.cs index 3825768d97..b178a1e710 100644 --- a/src/Umbraco.Infrastructure/Intall/InstallHelper.cs +++ b/src/Umbraco.Infrastructure/Intall/InstallHelper.cs @@ -115,8 +115,7 @@ namespace Umbraco.Web.Install get { var databaseSettings = _connectionStrings[Constants.System.UmbracoConnectionName]; - if (_globalSettings.ConfigurationStatus.IsNullOrWhiteSpace() - && databaseSettings.IsConnectionStringConfigured() == false) + if (databaseSettings.IsConnectionStringConfigured() == false) { //no version or conn string configured, must be a brand new install return true; diff --git a/src/Umbraco.Infrastructure/Intall/InstallSteps/NewInstallStep.cs b/src/Umbraco.Infrastructure/Intall/InstallSteps/NewInstallStep.cs index 658dbfbf5a..8824bdc38d 100644 --- a/src/Umbraco.Infrastructure/Intall/InstallSteps/NewInstallStep.cs +++ b/src/Umbraco.Infrastructure/Intall/InstallSteps/NewInstallStep.cs @@ -125,11 +125,6 @@ namespace Umbraco.Web.Install.InstallSteps { //now we have to check if this is really a new install, the db might be configured and might contain data var databaseSettings = _connectionStrings[Constants.System.UmbracoConnectionName]; - - //if there's already a version then there should def be a user but in some cases someone may have - // left a version number in there but cleared out their db conn string, in that case, it's really a new install. - if (_globalSettings.ConfigurationStatus.IsNullOrWhiteSpace() == false && databaseSettings != null) return false; - if (databaseSettings.IsConnectionStringConfigured() && _databaseBuilder.IsDatabaseConfigured) return _databaseBuilder.HasSomeNonDefaultUser() == false; diff --git a/src/Umbraco.Infrastructure/Intall/InstallSteps/SetUmbracoVersionStep.cs b/src/Umbraco.Infrastructure/Intall/InstallSteps/SetUmbracoVersionStep.cs index 4e4e590284..5bdd6624d5 100644 --- a/src/Umbraco.Infrastructure/Intall/InstallSteps/SetUmbracoVersionStep.cs +++ b/src/Umbraco.Infrastructure/Intall/InstallSteps/SetUmbracoVersionStep.cs @@ -49,10 +49,7 @@ namespace Umbraco.Web.Install.InstallSteps // // for installs, we need to log the super user in // security.PerformLogin(Constants.Security.SuperUserId); // } - - // Update configurationStatus - _globalSettings.ConfigurationStatus = _umbracoVersion.SemanticVersion.ToSemanticString(); - + //reports the ended install _installHelper.InstallStatus(true, ""); diff --git a/src/Umbraco.Infrastructure/Migrations/Install/DatabaseBuilder.cs b/src/Umbraco.Infrastructure/Migrations/Install/DatabaseBuilder.cs index 8f5969801c..f83608736f 100644 --- a/src/Umbraco.Infrastructure/Migrations/Install/DatabaseBuilder.cs +++ b/src/Umbraco.Infrastructure/Migrations/Install/DatabaseBuilder.cs @@ -362,9 +362,8 @@ namespace Umbraco.Core.Migrations.Install var hasInstalledVersion = schemaResult.DetermineHasInstalledVersion(); //var installedSchemaVersion = schemaResult.DetermineInstalledVersion(); //var hasInstalledVersion = !installedSchemaVersion.Equals(new Version(0, 0, 0)); - - //If Configuration Status is empty and the determined version is "empty" its a new install - otherwise upgrade the existing - if (string.IsNullOrEmpty(_globalSettings.ConfigurationStatus) && !hasInstalledVersion) + + if (!hasInstalledVersion) { if (_runtime.Level == RuntimeLevel.Run) throw new Exception("Umbraco is already configured!"); diff --git a/src/Umbraco.Infrastructure/Migrations/Upgrade/UmbracoPlan.cs b/src/Umbraco.Infrastructure/Migrations/Upgrade/UmbracoPlan.cs index dbf36da8f7..07fffbceb3 100644 --- a/src/Umbraco.Infrastructure/Migrations/Upgrade/UmbracoPlan.cs +++ b/src/Umbraco.Infrastructure/Migrations/Upgrade/UmbracoPlan.cs @@ -65,16 +65,10 @@ namespace Umbraco.Core.Migrations.Upgrade get { - // no state in database yet - assume we have something in web.config that makes some sense - if (!SemVersion.TryParse(_globalSettings.ConfigurationStatus, out var currentVersion)) - throw new InvalidOperationException($"Could not get current version from web.config {Constants.AppSettings.ConfigurationStatus} appSetting."); + var currentVersion = _umbracoVersion.SemanticVersion; - // cannot go back in time - if (currentVersion > _umbracoVersion.SemanticVersion) - throw new InvalidOperationException($"Version {currentVersion} cannot be downgraded to {_umbracoVersion.SemanticVersion}."); - - // only from 7.14.0 and above - var minVersion = new SemVersion(7, 14); + // only from 8.0.0 and above + var minVersion = new SemVersion(8, 0); if (currentVersion < minVersion) throw new InvalidOperationException($"Version {currentVersion} cannot be migrated to {_umbracoVersion.SemanticVersion}." + $" Please upgrade first to at least {minVersion}."); diff --git a/src/Umbraco.Infrastructure/RuntimeState.cs b/src/Umbraco.Infrastructure/RuntimeState.cs index d6f674f028..4f00e91e35 100644 --- a/src/Umbraco.Infrastructure/RuntimeState.cs +++ b/src/Umbraco.Infrastructure/RuntimeState.cs @@ -97,36 +97,36 @@ namespace Umbraco.Core /// public void DetermineRuntimeLevel(IUmbracoDatabaseFactory databaseFactory, ILogger logger) { - var localVersion = _umbracoVersion.LocalVersion; // the local, files, version - var codeVersion = SemanticVersion; // the executing code version - var connect = false; - - if (localVersion == null) - { - // there is no local version, we are not installed - logger.Debug("No local version, need to install Umbraco."); - Level = RuntimeLevel.Install; - Reason = RuntimeLevelReason.InstallNoVersion; - return; - } - - if (localVersion < codeVersion) - { - // there *is* a local version, but it does not match the code version - // need to upgrade - logger.Debug("Local version '{LocalVersion}' < code version '{CodeVersion}', need to upgrade Umbraco.", localVersion, codeVersion); - Level = RuntimeLevel.Upgrade; - Reason = RuntimeLevelReason.UpgradeOldVersion; - } - else if (localVersion > codeVersion) - { - logger.Warn("Local version '{LocalVersion}' > code version '{CodeVersion}', downgrading is not supported.", localVersion, codeVersion); - - // in fact, this is bad enough that we want to throw - Reason = RuntimeLevelReason.BootFailedCannotDowngrade; - throw new BootFailedException($"Local version \"{localVersion}\" > code version \"{codeVersion}\", downgrading is not supported."); - } - else if (databaseFactory.Configured == false) + // var localVersion = _umbracoVersion.LocalVersion; // the local, files, version + // var codeVersion = SemanticVersion; // the executing code version + var connect = false; + // + // if (localVersion == null) + // { + // // there is no local version, we are not installed + // logger.Debug("No local version, need to install Umbraco."); + // Level = RuntimeLevel.Install; + // Reason = RuntimeLevelReason.InstallNoVersion; + // return; + // } + // + // if (localVersion < codeVersion) + // { + // // there *is* a local version, but it does not match the code version + // // need to upgrade + // logger.Debug("Local version '{LocalVersion}' < code version '{CodeVersion}', need to upgrade Umbraco.", localVersion, codeVersion); + // Level = RuntimeLevel.Upgrade; + // Reason = RuntimeLevelReason.UpgradeOldVersion; + // } + // else if (localVersion > codeVersion) + // { + // logger.Warn("Local version '{LocalVersion}' > code version '{CodeVersion}', downgrading is not supported.", localVersion, codeVersion); + // + // // in fact, this is bad enough that we want to throw + // Reason = RuntimeLevelReason.BootFailedCannotDowngrade; + // throw new BootFailedException($"Local version \"{localVersion}\" > code version \"{codeVersion}\", downgrading is not supported."); + // } + if (databaseFactory.Configured == false) { // local version *does* match code version, but the database is not configured // install - may happen with Deploy/Cloud/etc diff --git a/src/Umbraco.PublishedCache.NuCache/DataSource/BTree.cs b/src/Umbraco.PublishedCache.NuCache/DataSource/BTree.cs index ad7cc72eec..00e7fd34d1 100644 --- a/src/Umbraco.PublishedCache.NuCache/DataSource/BTree.cs +++ b/src/Umbraco.PublishedCache.NuCache/DataSource/BTree.cs @@ -22,6 +22,13 @@ namespace Umbraco.Web.PublishedCache.NuCache.DataSource // default is 4096, min 2^9 = 512, max 2^16 = 64K FileBlockSize = GetBlockSize(settings), + + //HACK: Forces FileOptions to be WriteThrough here: https://github.com/mamift/CSharpTest.Net.Collections/blob/9f93733b3af7ee0e2de353e822ff54d908209b0b/src/CSharpTest.Net.Collections/IO/TransactedCompoundFile.cs#L316-L327, + // as the reflection uses otherwise will failed in .NET Core as the "_handle" field in FileStream is renamed to "_fileHandle". + StoragePerformance = StoragePerformance.CommitToDisk, + + + // other options? }; diff --git a/src/Umbraco.Tests.Common/SettingsForTests.cs b/src/Umbraco.Tests.Common/SettingsForTests.cs index 0f7836c788..1a14dc6bc1 100644 --- a/src/Umbraco.Tests.Common/SettingsForTests.cs +++ b/src/Umbraco.Tests.Common/SettingsForTests.cs @@ -22,7 +22,6 @@ namespace Umbraco.Tests.Common var config = Mock.Of( settings => - settings.ConfigurationStatus == semanticVersion.ToSemanticString() && settings.UseHttps == false && settings.HideTopLevelNodeFromPath == false && settings.TimeOutInMinutes == 20 && diff --git a/src/Umbraco.Tests/TestHelpers/TestWithDatabaseBase.cs b/src/Umbraco.Tests/TestHelpers/TestWithDatabaseBase.cs index 1245e7d59e..71465533d3 100644 --- a/src/Umbraco.Tests/TestHelpers/TestWithDatabaseBase.cs +++ b/src/Umbraco.Tests/TestHelpers/TestWithDatabaseBase.cs @@ -133,10 +133,6 @@ namespace Umbraco.Tests.TestHelpers CreateSqlCeDatabase(); // TODO: faster! } - // ensure the configuration matches the current version for tests - var globalSettingsMock = Mock.Get(Factory.GetInstance()); //this will modify the IGlobalSettings instance stored in the container - globalSettingsMock.Setup(x => x.ConfigurationStatus).Returns(UmbracoVersion.Current.ToString(3)); - using (ProfilingLogger.TraceDuration("Initialize database.")) { InitializeDatabase(); // TODO: faster! diff --git a/src/Umbraco.Web.Common/Extensions/UmbracoCoreServiceCollectionExtensions.cs b/src/Umbraco.Web.Common/Extensions/UmbracoCoreServiceCollectionExtensions.cs index 6f27f3e6bf..9616f4584a 100644 --- a/src/Umbraco.Web.Common/Extensions/UmbracoCoreServiceCollectionExtensions.cs +++ b/src/Umbraco.Web.Common/Extensions/UmbracoCoreServiceCollectionExtensions.cs @@ -85,7 +85,7 @@ namespace Umbraco.Web.Common.Extensions IHttpContextAccessor httpContextAccessor = new HttpContextAccessor(); services.AddSingleton(httpContextAccessor); - var requestCache = new GenericDictionaryRequestAppCache(() => httpContextAccessor.HttpContext.Items); + var requestCache = new GenericDictionaryRequestAppCache(() => httpContextAccessor.HttpContext?.Items); services.AddUmbracoCore(webHostEnvironment, umbContainer, diff --git a/src/Umbraco.Web.Common/Runtime/AspNetCoreComposer.cs b/src/Umbraco.Web.Common/Runtime/AspNetCoreComposer.cs index 332a405580..30d7cdaced 100644 --- a/src/Umbraco.Web.Common/Runtime/AspNetCoreComposer.cs +++ b/src/Umbraco.Web.Common/Runtime/AspNetCoreComposer.cs @@ -59,6 +59,9 @@ namespace Umbraco.Web.Common.Runtime composition.RegisterUnique(); + // register the umbraco context factory + composition.RegisterUnique(); + //register the install components //NOTE: i tried to not have these registered if we weren't installing or upgrading but post install when the site restarts //it still needs to use the install controller so we can't do that diff --git a/src/Umbraco.Web.UI.NetCore/Umbraco.Web.UI.NetCore.csproj b/src/Umbraco.Web.UI.NetCore/Umbraco.Web.UI.NetCore.csproj index 09d3e81e55..df916c50f9 100644 --- a/src/Umbraco.Web.UI.NetCore/Umbraco.Web.UI.NetCore.csproj +++ b/src/Umbraco.Web.UI.NetCore/Umbraco.Web.UI.NetCore.csproj @@ -6,6 +6,7 @@ + @@ -49,6 +50,7 @@ + diff --git a/src/Umbraco.Web.UI.NetCore/appsettings.Development.json b/src/Umbraco.Web.UI.NetCore/appsettings.Development.json index 834ea5f51f..8983e0fc1c 100644 --- a/src/Umbraco.Web.UI.NetCore/appsettings.Development.json +++ b/src/Umbraco.Web.UI.NetCore/appsettings.Development.json @@ -1,7 +1,4 @@ { - "ConnectionStrings": { - "umbracoDbDSN": "" - }, "Logging": { "LogLevel": { "Default": "Information", diff --git a/src/Umbraco.Web.UI.NetCore/appsettings.json b/src/Umbraco.Web.UI.NetCore/appsettings.json index 6cc0a49b4b..a60391aeda 100644 --- a/src/Umbraco.Web.UI.NetCore/appsettings.json +++ b/src/Umbraco.Web.UI.NetCore/appsettings.json @@ -1,5 +1,7 @@ { - "ConnectionStrings": {}, + "ConnectionStrings": { + "umbracoDbDSN": "Data Source=|DataDirectory|\\Umbraco.sdf;Flush Interval=1;" + }, "Logging": { "LogLevel": { "Default": "Information", @@ -117,4 +119,4 @@ } } } -} \ No newline at end of file +}