Database upgrade check was backwards &some more failsafes for upgrader/installer

This commit is contained in:
Sebastiaan Janssen
2013-01-07 09:39:39 -01:00
parent 759773deee
commit af4fbba8e8
4 changed files with 34 additions and 27 deletions

View File

@@ -234,16 +234,16 @@ namespace Umbraco.Core.Configuration
var xml = XDocument.Load(fileName, LoadOptions.PreserveWhitespace);
var appSettings = xml.Root.Descendants("appSettings").Single();
var setting = appSettings.Descendants("add").FirstOrDefault(s => s.Attribute("key").Value == key);
if (setting != null)
{
setting.Remove();
xml.Save(fileName, SaveOptions.DisableFormatting);
ConfigurationManager.RefreshSection("appSettings");
xml.Save(fileName, SaveOptions.DisableFormatting);
ConfigurationManager.RefreshSection("appSettings");
}
}
private static string GetFullWebConfigFileName()
{
var webConfig = new WebConfigurationFileMap();

View File

@@ -14,7 +14,7 @@ namespace umbraco.presentation.install.steps.Definitions
public override string Name
{
get { return "Database"; }
get { return "Database"; }
}
public override string UserControl
@@ -22,7 +22,7 @@ namespace umbraco.presentation.install.steps.Definitions
get { return SystemDirectories.Install + "/steps/database.ascx"; }
}
public override bool MoveToNextStepAutomaticly
{
get
@@ -34,22 +34,10 @@ namespace umbraco.presentation.install.steps.Definitions
//here we determine if the installer should skip this step...
public override bool Completed()
{
bool retval = false;
try
{
var configuredVersion = new Version(Umbraco.Core.Configuration.GlobalSettings.ConfigurationStatus);
var targetVersion = UmbracoVersion.Current;
retval = targetVersion > configuredVersion;
} catch {
// this step might fail due to missing connectionstring
return false;
}
return retval;
var configuredVersion = new Version(Umbraco.Core.Configuration.GlobalSettings.ConfigurationStatus);
var targetVersion = UmbracoVersion.Current;
return targetVersion < configuredVersion;
}
}
}

View File

@@ -1,4 +1,5 @@
using System;
using System.Configuration;
using System.Web.Script.Serialization;
using System.Web.Script.Services;
using System.Web.Services;
@@ -60,9 +61,18 @@ namespace umbraco.presentation.install.utills
var result = ApplicationContext.Current.DatabaseContext.CreateDatabaseSchemaAndDataOrUpgrade();
// Remove legacy umbracoDbDsn configuration setting if it exists
Umbraco.Core.Configuration.GlobalSettings.RemoveSetting(Umbraco.Core.Configuration.GlobalSettings.UmbracoConnectionName);
// Remove legacy umbracoDbDsn configuration setting if it exists and connectionstring also exists
if (ConfigurationManager.ConnectionStrings[Umbraco.Core.Configuration.GlobalSettings.UmbracoConnectionName] != null)
{
Umbraco.Core.Configuration.GlobalSettings.RemoveSetting(Umbraco.Core.Configuration.GlobalSettings.UmbracoConnectionName);
}
else
{
var ex = new ArgumentNullException(string.Format("ConfigurationManager.ConnectionStrings[{0}]", Umbraco.Core.Configuration.GlobalSettings.UmbracoConnectionName), "Install / upgrade did not complete successfully, umbracoDbDSN was not set in the connectionStrings section");
LogHelper.Error<p>("", ex);
throw ex;
}
var js = new JavaScriptSerializer();
var jsonResult = js.Serialize(result);
return jsonResult;

View File

@@ -311,9 +311,18 @@ namespace umbraco.BasePages
private void DeleteLogin()
{
SqlHelper.ExecuteNonQuery(
// Added try-catch in case login doesn't exist in the database
// Either due to old cookie or running multiple sessions on localhost with different port number
try
{
SqlHelper.ExecuteNonQuery(
"DELETE FROM umbracoUserLogins WHERE contextId = @contextId",
SqlHelper.CreateParameter("@contextId", umbracoUserContextID));
}
catch (Exception ex)
{
LogHelper.Error<BasePage>(string.Format("Login with contextId {0} didn't exist in the database", umbracoUserContextID), ex);
}
}
private void UpdateLogin()