Fixes: #U4-1547 - duplicate trees on upgrade in rare cases.

This commit is contained in:
Shannon Deminick
2013-01-28 19:36:06 +06:00
parent 0689b928c2
commit 2f00fa0791
3 changed files with 22 additions and 4 deletions

View File

@@ -20,6 +20,7 @@
<add application="developer" alias="datatype" title="Data Types" type="umbraco.loadDataTypes, umbraco" iconClosed=".sprTreeFolder" iconOpen=".sprTreeFolder_o" sortOrder="1" />
<add application="developer" alias="macros" title="Macros" type="umbraco.loadMacros, umbraco" iconClosed=".sprTreeFolder" iconOpen=".sprTreeFolder_o" sortOrder="2" />
<add application="developer" alias="packager" title="Packages" type="umbraco.loadPackager, umbraco" iconClosed="folder.gif" iconOpen="folder_o.gif" sortOrder="3" />
<add application="developer" alias="packager" title="Packages" type="umbraco.loadPackager, umbraco" iconClosed="folder.gif" iconOpen="folder_o.gif" sortOrder="3" />
<add application="developer" alias="packagerPackages" title="Packager Packages" type="umbraco.loadPackages, umbraco" iconClosed="folder.gif" iconOpen="folder_o.gif" initialize="false" sortOrder="3" />
<add application="developer" alias="relationTypes" title="Relation Types" type="umbraco.loadRelationTypes, umbraco" iconClosed=".sprTreeFolder" iconOpen=".sprTreeFolder_o" sortOrder="4" />
<add application="developer" alias="python" title="Scripting Files" type="umbraco.loadPython, umbraco" iconClosed="folder.gif" iconOpen="folder_o.gif" sortOrder="4" />

View File

@@ -4,6 +4,7 @@ using System.IO;
using System.Linq;
using System.Web;
using System.Xml.Linq;
using Umbraco.Core;
using umbraco.DataLayer;
using umbraco.IO;
@@ -395,7 +396,18 @@ namespace umbraco.BusinessLogic
return sortOrderAttr != null ? Convert.ToInt32(sortOrderAttr.Value) : 0;
}))
{
list.Add(new ApplicationTree(
var applicationAlias = (string)addElement.Attribute("application");
var type = (string)addElement.Attribute("type");
var assembly = (string)addElement.Attribute("assembly");
//check if the tree definition (applicationAlias + type + assembly) is already in the list
if (!list.Any(tree => tree.ApplicationAlias.InvariantEquals(applicationAlias)
&& tree.Type.InvariantEquals(type)
&& tree.AssemblyName.InvariantEquals(assembly)))
{
list.Add(new ApplicationTree(
addElement.Attribute("silent") != null ? Convert.ToBoolean(addElement.Attribute("silent").Value) : false,
addElement.Attribute("initialize") != null ? Convert.ToBoolean(addElement.Attribute("initialize").Value) : true,
addElement.Attribute("sortOrder") != null ? Convert.ToByte(addElement.Attribute("sortOrder").Value) : (byte)0,
@@ -404,9 +416,12 @@ namespace umbraco.BusinessLogic
addElement.Attribute("title").Value,
addElement.Attribute("iconClosed").Value,
addElement.Attribute("iconOpen").Value,
(string)addElement.Attribute("assembly"), //this could be empty: http://issues.umbraco.org/issue/U4-1360
(string)addElement.Attribute("assembly"), //this could be empty: http://issues.umbraco.org/issue/U4-1360
addElement.Attribute("type").Value,
addElement.Attribute("action") != null ? addElement.Attribute("action").Value : ""));
}
}
}, false);

View File

@@ -13,8 +13,10 @@ namespace umbraco.BusinessLogic
{
public ApplicationTreeRegistrar()
{
//don't do anything if the application is not configured!
if (ApplicationContext.Current == null || !ApplicationContext.Current.IsConfigured)
//don't do anything if the application or database is not configured!
if (ApplicationContext.Current == null
|| !ApplicationContext.Current.IsConfigured
|| !ApplicationContext.Current.DatabaseContext.IsDatabaseConfigured)
return;
// Load all Trees by attribute and add them to the XML config