diff --git a/src/Umbraco.Core/ApplicationContext.cs b/src/Umbraco.Core/ApplicationContext.cs
index 79180550f0..ca54afb7b1 100644
--- a/src/Umbraco.Core/ApplicationContext.cs
+++ b/src/Umbraco.Core/ApplicationContext.cs
@@ -1,6 +1,7 @@
using System;
using System.Configuration;
using System.Threading;
+using Semver;
using Umbraco.Core.Configuration;
using Umbraco.Core.Logging;
using Umbraco.Core.ObjectResolution;
@@ -341,6 +342,52 @@ namespace Umbraco.Core
}
}
+ ///
+ /// Gets the Current Version of the Umbraco Site before an upgrade
+ /// by using the last/most recent Umbraco Migration that has been run
+ ///
+ /// A SemVersion of the latest Umbraco DB Migration run
+ ///
+ /// NOTE: This existed in the InstallHelper previously but should really be here so it can be re-used if necessary
+ ///
+ internal SemVersion CurrentVersion()
+ {
+ //Set a default version of 0.0.0
+ var version = new SemVersion(0);
+
+ //If we have a db context available, if we don't then we are not installed anyways
+ if (DatabaseContext.IsDatabaseConfigured && DatabaseContext.CanConnect)
+ version = DatabaseContext.ValidateDatabaseSchema().DetermineInstalledVersionByMigrations(Services.MigrationEntryService);
+
+ if (version != new SemVersion(0))
+ return version;
+
+ // If we aren't able to get a result from the umbracoMigrations table then use the version in web.config, if it's available
+ if (string.IsNullOrWhiteSpace(GlobalSettings.ConfigurationStatus))
+ return version;
+
+ var configuredVersion = GlobalSettings.ConfigurationStatus;
+
+ string currentComment = null;
+
+ var current = configuredVersion.Split('-');
+ if (current.Length > 1)
+ currentComment = current[1];
+
+ Version currentVersion;
+ if (Version.TryParse(current[0], out currentVersion))
+ {
+ version = new SemVersion(
+ currentVersion.Major,
+ currentVersion.Minor,
+ currentVersion.Build,
+ string.IsNullOrWhiteSpace(currentComment) ? null : currentComment,
+ currentVersion.Revision > 0 ? currentVersion.Revision.ToString() : null);
+ }
+
+ return version;
+ }
+
private void AssertIsNotReady()
{
if (this.IsReady)
diff --git a/src/Umbraco.Core/Security/BackOfficeCookieAuthenticationProvider.cs b/src/Umbraco.Core/Security/BackOfficeCookieAuthenticationProvider.cs
index 0a51359bde..3ff1266c6b 100644
--- a/src/Umbraco.Core/Security/BackOfficeCookieAuthenticationProvider.cs
+++ b/src/Umbraco.Core/Security/BackOfficeCookieAuthenticationProvider.cs
@@ -9,6 +9,7 @@ using System.Threading.Tasks;
using Microsoft.AspNet.Identity;
using Microsoft.Owin;
using Microsoft.Owin.Security.Cookies;
+using Semver;
using Umbraco.Core.Configuration;
using Umbraco.Core.Models.Identity;
@@ -31,6 +32,8 @@ namespace Umbraco.Core.Security
_appCtx = appCtx;
}
+ private static readonly SemVersion MinUmbracoVersionSupportingLoginSessions = new SemVersion(7, 8);
+
public override void ResponseSignIn(CookieResponseSignInContext context)
{
var backOfficeIdentity = context.Identity as UmbracoBackOfficeIdentity;
@@ -39,7 +42,10 @@ namespace Umbraco.Core.Security
//generate a session id and assign it
//create a session token - if we are configured and not in an upgrade state then use the db, otherwise just generate one
- var session = _appCtx.IsConfigured && _appCtx.IsUpgrading == false
+ //NOTE - special check because when we are upgrading to 7.8 we cannot create a session since the db isn't ready and we'll get exceptions
+ var canAcquireSession = _appCtx.IsUpgrading == false || _appCtx.CurrentVersion() >= MinUmbracoVersionSupportingLoginSessions;
+
+ var session = canAcquireSession
? _appCtx.Services.UserService.CreateLoginSession((int)backOfficeIdentity.Id, context.OwinContext.GetCurrentRequestIpAddress())
: Guid.NewGuid();
diff --git a/src/Umbraco.Web/Install/InstallHelper.cs b/src/Umbraco.Web/Install/InstallHelper.cs
index a3069342fc..b2c3d1213d 100644
--- a/src/Umbraco.Web/Install/InstallHelper.cs
+++ b/src/Umbraco.Web/Install/InstallHelper.cs
@@ -8,6 +8,7 @@ using System.Net.Http;
using System.Web;
using System.Web.Script.Serialization;
using System.Web.UI;
+using Semver;
using umbraco.BusinessLogic;
using Umbraco.Core;
using Umbraco.Core.Configuration;
@@ -30,7 +31,6 @@ namespace Umbraco.Web.Install
_umbContext = umbContext;
}
-
///
/// Get the installer steps
///
@@ -43,7 +43,7 @@ namespace Umbraco.Web.Install
return new List
{
new NewInstallStep(_umbContext.HttpContext, _umbContext.Application),
- new UpgradeStep(),
+ new UpgradeStep(_umbContext.Application),
new FilePermissionsStep(),
new MajorVersion7UpgradeReport(_umbContext.Application),
new Version73FileCleanup(_umbContext.HttpContext, _umbContext.Application.ProfilingLogger.Logger),
diff --git a/src/Umbraco.Web/Install/InstallSteps/UpgradeStep.cs b/src/Umbraco.Web/Install/InstallSteps/UpgradeStep.cs
index 5ef2577179..902cae8096 100644
--- a/src/Umbraco.Web/Install/InstallSteps/UpgradeStep.cs
+++ b/src/Umbraco.Web/Install/InstallSteps/UpgradeStep.cs
@@ -14,6 +14,13 @@ namespace Umbraco.Web.Install.InstallSteps
"Upgrade", "upgrade", 1, "Upgrading Umbraco to the latest and greatest version.")]
internal class UpgradeStep : InstallSetupStep