Fixes: U4-4154 convert existing property data from XML to JSON during upgrade v6 - 7 to ensure that other data types that have this property editor are upgraded as well. Fixes some of the installer bits so that the steps are not marked as completed if they have problems.
This commit is contained in:
@@ -26,74 +26,56 @@ namespace Umbraco.Core.Persistence.Migrations.Upgrades.TargetVersionSeven
|
||||
{
|
||||
if (database != null)
|
||||
{
|
||||
try
|
||||
var dtSql = new Sql().Select("nodeId").From<DataTypeDto>().Where<DataTypeDto>(dto => dto.PropertyEditorAlias == Constants.PropertyEditors.RelatedLinksAlias);
|
||||
var dataTypeIds = database.Fetch<int>(dtSql);
|
||||
|
||||
var propertyData =
|
||||
database.Fetch<PropertyDataDto>(
|
||||
"WHERE propertyTypeId in (SELECT id from cmsPropertyType where dataTypeID IN (@dataTypeIds))", new { dataTypeIds = dataTypeIds });
|
||||
foreach (var data in propertyData)
|
||||
{
|
||||
var propertyData =
|
||||
database.Fetch<PropertyDataDto>(
|
||||
"WHERE propertyTypeId in (SELECT id from cmsPropertyType where dataTypeID = 1040)");
|
||||
foreach (var data in propertyData)
|
||||
if (!string.IsNullOrEmpty(data.Text))
|
||||
{
|
||||
if (!string.IsNullOrEmpty(data.Text))
|
||||
//var cs = ApplicationContext.Current.Services.ContentService;
|
||||
|
||||
//fetch the current data (that's in xml format)
|
||||
var xml = new XmlDocument();
|
||||
xml.LoadXml(data.Text);
|
||||
|
||||
if (xml != null)
|
||||
{
|
||||
//var cs = ApplicationContext.Current.Services.ContentService;
|
||||
var links = new List<ExpandoObject>();
|
||||
|
||||
//fetch the current data (that's in xml format)
|
||||
var xml = new XmlDocument();
|
||||
xml.LoadXml(data.Text);
|
||||
|
||||
if (xml != null)
|
||||
//loop all the stored links
|
||||
foreach (XmlNode node in xml.DocumentElement.ChildNodes)
|
||||
{
|
||||
var links = new List<ExpandoObject>();
|
||||
var title = node.Attributes["title"].Value;
|
||||
var type = node.Attributes["type"].Value;
|
||||
var newwindow = node.Attributes["newwindow"].Value.Equals("1") ? true : false;
|
||||
var lnk = node.Attributes["link"].Value;
|
||||
|
||||
//loop all the stored links
|
||||
foreach (XmlNode node in xml.DocumentElement.ChildNodes)
|
||||
{
|
||||
var title = node.Attributes["title"].Value;
|
||||
var type = node.Attributes["type"].Value;
|
||||
var newwindow = node.Attributes["newwindow"].Value.Equals("1") ? true : false;
|
||||
var lnk = node.Attributes["link"].Value;
|
||||
//create the links in the format the new prop editor expects it to be
|
||||
var link = new ExpandoObject() as IDictionary<string, Object>;
|
||||
link.Add("title", title);
|
||||
link.Add("caption", title);
|
||||
link.Add("link", lnk);
|
||||
link.Add("newWindow", newwindow);
|
||||
link.Add("type", type.Equals("internal") ? "internal" : "external");
|
||||
link.Add("internal", type.Equals("internal") ? lnk : null);
|
||||
|
||||
//create the links in the format the new prop editor expects it to be
|
||||
var link = new ExpandoObject() as IDictionary<string, Object>;
|
||||
link.Add("title", title);
|
||||
link.Add("caption", title);
|
||||
link.Add("link", lnk);
|
||||
link.Add("newWindow", newwindow);
|
||||
link.Add("type", type.Equals("internal") ? "internal" : "external");
|
||||
link.Add("internal", type.Equals("internal") ? lnk : null);
|
||||
|
||||
link.Add("edit", false);
|
||||
link.Add("isInternal", type.Equals("internal"));
|
||||
link.Add("edit", false);
|
||||
link.Add("isInternal", type.Equals("internal"));
|
||||
|
||||
//try
|
||||
//{
|
||||
// if (type.Equals("internal"))
|
||||
// {
|
||||
// int nodeId;
|
||||
// if (int.TryParse(lnk, out nodeId))
|
||||
// link.Add("internalName", cs.GetById(nodeId).Name);
|
||||
// }
|
||||
//}
|
||||
//catch (Exception ex)
|
||||
//{
|
||||
// LogHelper.Error<UpdateRelatedLinksData>("Exception was thrown when trying to update related links property data, fetching internal node id", ex);
|
||||
//}
|
||||
|
||||
links.Add((ExpandoObject) link);
|
||||
}
|
||||
|
||||
//store the serialized data
|
||||
data.Text = JsonConvert.SerializeObject(links);
|
||||
|
||||
database.Update(data);
|
||||
links.Add((ExpandoObject)link);
|
||||
}
|
||||
|
||||
//store the serialized data
|
||||
data.Text = JsonConvert.SerializeObject(links);
|
||||
|
||||
database.Update(data);
|
||||
}
|
||||
}
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
LogHelper.Error<UpdateRelatedLinksData>("Exception was thrown when trying to update related links property data", ex);
|
||||
}
|
||||
}
|
||||
return string.Empty;
|
||||
}
|
||||
|
||||
@@ -26,5 +26,19 @@ namespace Umbraco.Web.Install
|
||||
View = view;
|
||||
ViewModel = viewModel;
|
||||
}
|
||||
|
||||
public InstallException(string message, object viewModel)
|
||||
{
|
||||
_message = message;
|
||||
View = "error";
|
||||
ViewModel = viewModel;
|
||||
}
|
||||
|
||||
public InstallException(string message)
|
||||
{
|
||||
_message = message;
|
||||
View = "error";
|
||||
ViewModel = null;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -37,7 +37,7 @@ namespace Umbraco.Web.Install.InstallSteps
|
||||
|
||||
if (dbHelper.CheckConnection(database, _applicationContext) == false)
|
||||
{
|
||||
throw new InvalidOperationException("Could not connect to the database");
|
||||
throw new InstallException("Could not connect to the database");
|
||||
}
|
||||
ConfigureConnection(database);
|
||||
return null;
|
||||
|
||||
@@ -25,11 +25,7 @@ namespace Umbraco.Web.Install.InstallSteps
|
||||
|
||||
if (result.Success == false)
|
||||
{
|
||||
return new InstallSetupResult("error",
|
||||
new
|
||||
{
|
||||
message = "The database failed to install. ERROR: " + result.Message
|
||||
});
|
||||
throw new InstallException("The database failed to install. ERROR: " + result.Message);
|
||||
}
|
||||
|
||||
if (result.RequiresUpgrade == false)
|
||||
|
||||
@@ -34,11 +34,7 @@ namespace Umbraco.Web.Install.InstallSteps
|
||||
|
||||
if (result.Success == false)
|
||||
{
|
||||
return new InstallSetupResult("error",
|
||||
new
|
||||
{
|
||||
message = "The database failed to upgrade. ERROR: " + result.Message
|
||||
});
|
||||
throw new InstallException("The database failed to upgrade. ERROR: " + result.Message);
|
||||
}
|
||||
|
||||
DatabaseInstallStep.HandleConnectionStrings();
|
||||
|
||||
@@ -27,14 +27,7 @@ namespace Umbraco.Web.Install.InstallSteps
|
||||
public override InstallSetupResult Execute(object model)
|
||||
{
|
||||
// Update configurationStatus
|
||||
try
|
||||
{
|
||||
GlobalSettings.ConfigurationStatus = UmbracoVersion.Current.ToString(3);
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
LogHelper.Error<SetUmbracoVersionStep>("An error occurred updating the config status", ex);
|
||||
}
|
||||
GlobalSettings.ConfigurationStatus = UmbracoVersion.Current.ToString(3);
|
||||
|
||||
// Update ClientDependency version
|
||||
var clientDependencyConfig = new ClientDependencyConfiguration();
|
||||
|
||||
@@ -53,11 +53,11 @@ namespace Umbraco.Web.Install.InstallSteps
|
||||
var repo = global::umbraco.cms.businesslogic.packager.repositories.Repository.getByGuid(RepoGuid);
|
||||
if (repo == null)
|
||||
{
|
||||
throw new InvalidOperationException("No repository found with id " + RepoGuid);
|
||||
throw new InstallException("No repository found with id " + RepoGuid);
|
||||
}
|
||||
if (repo.HasConnection() == false)
|
||||
{
|
||||
throw new InvalidOperationException("Cannot connect to repository");
|
||||
throw new InstallException("Cannot connect to repository");
|
||||
}
|
||||
var installer = new Installer();
|
||||
|
||||
|
||||
Reference in New Issue
Block a user