U4-7681 Legacy CMSNode.Parent uses old SqlHelper API and doesn't keep a reference
This commit is contained in:
@@ -191,7 +191,7 @@ namespace umbraco
|
||||
// check if document *is* published, it could be unpublished by an event
|
||||
if (d.Published)
|
||||
{
|
||||
var parentId = d.Level == 1 ? -1 : d.Parent.Id;
|
||||
var parentId = d.Level == 1 ? -1 : d.ParentId;
|
||||
|
||||
// fix sortOrder - see note in UpdateSortOrder
|
||||
var node = GetPreviewOrPublishedNode(d, xmlContentCopy, false);
|
||||
|
||||
@@ -70,7 +70,7 @@ namespace umbraco
|
||||
var docParentId = -1;
|
||||
try
|
||||
{
|
||||
docParentId = document.Parent.Id;
|
||||
docParentId = document.ParentId;
|
||||
}
|
||||
catch (ArgumentException)
|
||||
{
|
||||
|
||||
@@ -93,7 +93,7 @@ namespace umbraco.presentation.channels
|
||||
p.dateCreated = d.CreateDateTime;
|
||||
p.page_title = d.Text;
|
||||
p.page_id = d.Id;
|
||||
p.page_parent_id = d.Parent.Id;
|
||||
p.page_parent_id = d.ParentId;
|
||||
|
||||
blogPostsObjects.Add(p);
|
||||
}
|
||||
@@ -150,7 +150,7 @@ namespace umbraco.presentation.channels
|
||||
p.dateCreated = d.CreateDateTime;
|
||||
p.title = d.Text;
|
||||
p.page_id = d.Id;
|
||||
p.wp_page_parent_id = d.Parent.Id;
|
||||
p.wp_page_parent_id = d.ParentId;
|
||||
p.wp_page_parent_title = d.Parent.Text;
|
||||
p.permalink = library.NiceUrl(d.Id);
|
||||
p.description = d.getProperty(userChannel.FieldDescriptionAlias).Value.ToString();
|
||||
|
||||
@@ -83,7 +83,7 @@ namespace umbraco.presentation.preview
|
||||
|
||||
var previewNodes = new List<Document>();
|
||||
|
||||
var parentId = documentObject.Level == 1 ? -1 : documentObject.Parent.Id;
|
||||
var parentId = documentObject.Level == 1 ? -1 : documentObject.ParentId;
|
||||
|
||||
while (parentId > 0 && XmlContent.GetElementById(parentId.ToString(CultureInfo.InvariantCulture)) == null)
|
||||
{
|
||||
@@ -97,7 +97,7 @@ namespace umbraco.presentation.preview
|
||||
foreach (var document in previewNodes)
|
||||
{
|
||||
//Inject preview xml
|
||||
parentId = document.Level == 1 ? -1 : document.Parent.Id;
|
||||
parentId = document.Level == 1 ? -1 : document.ParentId;
|
||||
var previewXml = document.ToPreviewXml(XmlContent);
|
||||
if (document.ContentEntity.Published == false
|
||||
&& ApplicationContext.Current.Services.ContentService.HasPublishedVersion(document.Id))
|
||||
|
||||
@@ -19,13 +19,13 @@ namespace umbraco
|
||||
/// <returns>Media nodes as IEnumerable</returns>
|
||||
public static IEnumerable<Media> GetAncestorMedia(this Media media)
|
||||
{
|
||||
var ancestor = new Media(media.Parent.Id);
|
||||
var ancestor = new Media(media.ParentId);
|
||||
|
||||
while (ancestor != null && ancestor.Id != -1)
|
||||
{
|
||||
yield return ancestor;
|
||||
|
||||
ancestor = new Media(ancestor.Parent.Id);
|
||||
ancestor = new Media(ancestor.ParentId);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -53,7 +53,7 @@ namespace umbraco
|
||||
{
|
||||
if (media.Parent != null)
|
||||
{
|
||||
var parentMedia = new Media(media.Parent.Id);
|
||||
var parentMedia = new Media(media.ParentId);
|
||||
|
||||
foreach (var siblingMedia in parentMedia.GetChildMedia().Where(childMedia => childMedia.Id != media.Id))
|
||||
{
|
||||
|
||||
@@ -617,6 +617,7 @@ order by level,sortOrder";
|
||||
/// </summary>
|
||||
/// <param name="NewParentId">Target CMSNode id</param>
|
||||
[Obsolete("Obsolete, Use Umbraco.Core.Services.ContentService.Move() or Umbraco.Core.Services.MediaService.Move()", false)]
|
||||
[EditorBrowsable(EditorBrowsableState.Never)]
|
||||
public virtual void Move(int newParentId)
|
||||
{
|
||||
CMSNode parent = new CMSNode(newParentId);
|
||||
@@ -796,6 +797,7 @@ order by level,sortOrder";
|
||||
internal set { _parentid = value; }
|
||||
}
|
||||
|
||||
private IUmbracoEntity _parent;
|
||||
/// <summary>
|
||||
/// Given the hierarchical tree structure a CMSNode has only one newParent but can have many children
|
||||
/// </summary>
|
||||
@@ -805,15 +807,21 @@ order by level,sortOrder";
|
||||
get
|
||||
{
|
||||
if (Level == 1) throw new ArgumentException("No newParent node");
|
||||
return new CMSNode(_parentid);
|
||||
if (_parent == null)
|
||||
{
|
||||
_parent = ApplicationContext.Current.Services.EntityService.Get(Entity.ParentId);
|
||||
}
|
||||
return new CMSNode(_parent);
|
||||
}
|
||||
set
|
||||
{
|
||||
_parentid = value.Id;
|
||||
SqlHelper.ExecuteNonQuery("update umbracoNode set parentId = " + value.Id.ToString() + " where id = " + this.Id.ToString());
|
||||
SqlHelper.ExecuteNonQuery("update umbracoNode set parentId = " + value.Id + " where id = " + this.Id.ToString());
|
||||
|
||||
if (Entity != null)
|
||||
Entity.ParentId = value.Id;
|
||||
|
||||
_parent = value.Entity;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1183,7 +1191,7 @@ order by level,sortOrder";
|
||||
x.Attributes.Append(xmlHelper.addAttribute(xd, "id", this.Id.ToString()));
|
||||
x.Attributes.Append(xmlHelper.addAttribute(xd, "key", this.UniqueId.ToString()));
|
||||
if (this.Level > 1)
|
||||
x.Attributes.Append(xmlHelper.addAttribute(xd, "parentID", this.Parent.Id.ToString()));
|
||||
x.Attributes.Append(xmlHelper.addAttribute(xd, "parentID", this.ParentId.ToString()));
|
||||
else
|
||||
x.Attributes.Append(xmlHelper.addAttribute(xd, "parentID", "-1"));
|
||||
x.Attributes.Append(xmlHelper.addAttribute(xd, "level", this.Level.ToString()));
|
||||
|
||||
@@ -115,6 +115,14 @@ namespace umbraco.cms.businesslogic
|
||||
|
||||
#region Public Properties
|
||||
|
||||
/// <summary>
|
||||
/// Get the newParent id of the node
|
||||
/// </summary>
|
||||
public override int ParentId
|
||||
{
|
||||
get { return ContentBase == null ? base.ParentId : ContentBase.ParentId; }
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// The current Content objects ContentType, which defines the Properties of the Content (data)
|
||||
/// </summary>
|
||||
@@ -411,7 +419,7 @@ namespace umbraco.cms.businesslogic
|
||||
x.Attributes.Append(XmlHelper.AddAttribute(xd, "key", this.UniqueId.ToString()));
|
||||
x.Attributes.Append(XmlHelper.AddAttribute(xd, "version", this.Version.ToString()));
|
||||
if (this.Level > 1)
|
||||
x.Attributes.Append(XmlHelper.AddAttribute(xd, "parentID", this.Parent.Id.ToString()));
|
||||
x.Attributes.Append(XmlHelper.AddAttribute(xd, "parentID", this.ParentId.ToString()));
|
||||
else
|
||||
x.Attributes.Append(XmlHelper.AddAttribute(xd, "parentID", "-1"));
|
||||
x.Attributes.Append(XmlHelper.AddAttribute(xd, "level", this.Level.ToString()));
|
||||
|
||||
@@ -473,7 +473,7 @@ namespace umbraco.cms.businesslogic.web
|
||||
#endregion
|
||||
|
||||
#region Public Properties
|
||||
|
||||
|
||||
public override int sortOrder
|
||||
{
|
||||
get
|
||||
@@ -514,10 +514,7 @@ namespace umbraco.cms.businesslogic.web
|
||||
|
||||
public override int ParentId
|
||||
{
|
||||
get
|
||||
{
|
||||
return ContentEntity == null ? base.ParentId : ContentEntity.ParentId;
|
||||
}
|
||||
get { return ContentEntity == null ? base.ParentId : ContentEntity.ParentId; }
|
||||
}
|
||||
|
||||
public override string Path
|
||||
@@ -1291,7 +1288,7 @@ namespace umbraco.cms.businesslogic.web
|
||||
x.Attributes.Append(addAttribute(xd, "key", UniqueId.ToString()));
|
||||
// x.Attributes.Append(addAttribute(xd, "version", Version.ToString()));
|
||||
if (Level > 1)
|
||||
x.Attributes.Append(addAttribute(xd, "parentID", Parent.Id.ToString()));
|
||||
x.Attributes.Append(addAttribute(xd, "parentID", ParentId.ToString()));
|
||||
else
|
||||
x.Attributes.Append(addAttribute(xd, "parentID", "-1"));
|
||||
x.Attributes.Append(addAttribute(xd, "level", Level.ToString()));
|
||||
|
||||
Reference in New Issue
Block a user