Fixes: U4-4373 @Library.NodeById(-1).Id returns "0" instead of "-1"(6.2.0 beta) & U4-4374 @Model.NodeById(-1).DescendantsOrSelf().First().Id results in Excecption (6.2.0 beta)

This commit is contained in:
Shannon
2014-03-17 12:27:37 +11:00
parent 4745995f92
commit bbeedb6c1b
2 changed files with 24 additions and 2 deletions

View File

@@ -34,7 +34,7 @@ namespace Umbraco.Web.umbraco.presentation
if (doc == null)
{
Id = -1;
Id = 0;
return;
}

View File

@@ -32,6 +32,16 @@ namespace umbraco.MacroEngines
}
public DynamicBackingItem(int Id)
{
if (Id == -1)
{
//this is a special check, previously passing in -1 would return a real node, the root node. Though
// it has no properties (defaults apply), you could access descendants, children, etc...
//This is how this used to work before a large refactor - which I think may have broken other legacy logic too :(
this.content = new NodeFactory.Node(Id);
return;
}
var n = CompatibilityHelper.ConvertToNode(UmbracoContext.Current.ContentCache.GetById(Id));
this.content = n;
@@ -57,7 +67,19 @@ namespace umbraco.MacroEngines
}
else
{
this.content = CompatibilityHelper.ConvertToNode(UmbracoContext.Current.ContentCache.GetById(Id));
if (Id == -1)
{
//this is a special check, previously passing in -1 would return a real node, the root node. Though
// it has no properties (defaults apply), you could access descendants, children, etc...
//This is how this used to work before a large refactor - which I think may have broken other legacy logic too :(
this.content = new NodeFactory.Node(Id);
}
else
{
this.content = CompatibilityHelper.ConvertToNode(UmbracoContext.Current.ContentCache.GetById(Id));
}
this.Type = Type;
}
}