Cleanup NuCache/PublishedContent
This commit is contained in:
@@ -243,7 +243,7 @@ namespace Umbraco.Web.PublishedCache.NuCache
|
||||
var n = _snapshot.Get(contentId);
|
||||
if (n == null) return false;
|
||||
|
||||
return preview || n.Published != null;
|
||||
return preview || n.PublishedModel != null;
|
||||
}
|
||||
|
||||
public override IEnumerable<IPublishedContent> GetAtRoot(bool preview)
|
||||
@@ -280,8 +280,8 @@ namespace Umbraco.Web.PublishedCache.NuCache
|
||||
// both .Draft and .Published cannot be null at the same time
|
||||
|
||||
return preview
|
||||
? node.Draft ?? GetPublishedContentAsDraft(node.Published)
|
||||
: node.Published;
|
||||
? node.DraftModel ?? GetPublishedContentAsDraft(node.PublishedModel)
|
||||
: node.PublishedModel;
|
||||
}
|
||||
|
||||
// gets a published content as a previewing draft, if preview is true
|
||||
@@ -302,7 +302,7 @@ namespace Umbraco.Web.PublishedCache.NuCache
|
||||
{
|
||||
return preview
|
||||
? _snapshot.IsEmpty == false
|
||||
: _snapshot.GetAtRoot().Any(x => x.Published != null);
|
||||
: _snapshot.GetAtRoot().Any(x => x.PublishedModel != null);
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
@@ -67,9 +67,9 @@ namespace Umbraco.Web.PublishedCache.NuCache
|
||||
throw new ArgumentException("Both draftData and publishedData cannot be null at the same time.");
|
||||
|
||||
if (draftData != null)
|
||||
Draft = new PublishedContent(this, draftData, publishedSnapshotAccessor, variationContextAccessor).CreateModel();
|
||||
DraftModel = new PublishedContent(this, draftData, publishedSnapshotAccessor, variationContextAccessor).CreateModel();
|
||||
if (publishedData != null)
|
||||
Published = new PublishedContent(this, publishedData, publishedSnapshotAccessor, variationContextAccessor).CreateModel();
|
||||
PublishedModel = new PublishedContent(this, publishedData, publishedSnapshotAccessor, variationContextAccessor).CreateModel();
|
||||
}
|
||||
|
||||
// clone parent
|
||||
@@ -88,11 +88,11 @@ namespace Umbraco.Web.PublishedCache.NuCache
|
||||
CreateDate = origin.CreateDate;
|
||||
CreatorId = origin.CreatorId;
|
||||
|
||||
var originDraft = origin.Draft == null ? null : PublishedContent.UnwrapIPublishedContent(origin.Draft);
|
||||
var originPublished = origin.Published == null ? null : PublishedContent.UnwrapIPublishedContent(origin.Published);
|
||||
var originDraft = origin.DraftModel == null ? null : PublishedContent.UnwrapIPublishedContent(origin.DraftModel);
|
||||
var originPublished = origin.PublishedModel == null ? null : PublishedContent.UnwrapIPublishedContent(origin.PublishedModel);
|
||||
|
||||
Draft = originDraft == null ? null : new PublishedContent(this, originDraft).CreateModel();
|
||||
Published = originPublished == null ? null : new PublishedContent(this, originPublished).CreateModel();
|
||||
DraftModel = originDraft == null ? null : new PublishedContent(this, originDraft).CreateModel();
|
||||
PublishedModel = originPublished == null ? null : new PublishedContent(this, originPublished).CreateModel();
|
||||
|
||||
ChildContentIds = new List<int>(origin.ChildContentIds); // needs to be *another* list
|
||||
}
|
||||
@@ -110,11 +110,13 @@ namespace Umbraco.Web.PublishedCache.NuCache
|
||||
CreateDate = origin.CreateDate;
|
||||
CreatorId = origin.CreatorId;
|
||||
|
||||
var originDraft = origin.Draft == null ? null : PublishedContent.UnwrapIPublishedContent(origin.Draft);
|
||||
var originPublished = origin.Published == null ? null : PublishedContent.UnwrapIPublishedContent(origin.Published);
|
||||
var originDraft = origin.DraftModel == null ? null : PublishedContent.UnwrapIPublishedContent(origin.DraftModel);
|
||||
var originPublished = origin.PublishedModel == null ? null : PublishedContent.UnwrapIPublishedContent(origin.PublishedModel);
|
||||
|
||||
Draft = originDraft == null ? null : new PublishedContent(this, originDraft._contentData, publishedSnapshotAccessor, variationContextAccessor).CreateModel();
|
||||
Published = originPublished == null ? null : new PublishedContent(this, originPublished._contentData, publishedSnapshotAccessor, variationContextAccessor).CreateModel();
|
||||
DraftContent = originDraft == null ? null : new PublishedContent(this, originDraft._contentData, publishedSnapshotAccessor, variationContextAccessor);
|
||||
DraftModel = DraftContent?.CreateModel();
|
||||
PublishedContent = originPublished == null ? null : new PublishedContent(this, originPublished._contentData, publishedSnapshotAccessor, variationContextAccessor);
|
||||
PublishedModel = PublishedContent?.CreateModel();
|
||||
|
||||
ChildContentIds = origin.ChildContentIds; // can be the *same* list
|
||||
}
|
||||
@@ -132,10 +134,15 @@ namespace Umbraco.Web.PublishedCache.NuCache
|
||||
public readonly DateTime CreateDate;
|
||||
public readonly int CreatorId;
|
||||
|
||||
// draft and published version (either can be null, but not both)
|
||||
// are the direct PublishedContent instances
|
||||
public PublishedContent DraftContent;
|
||||
public PublishedContent PublishedContent;
|
||||
|
||||
// draft and published version (either can be null, but not both)
|
||||
// are models not direct PublishedContent instances
|
||||
public IPublishedContent Draft;
|
||||
public IPublishedContent Published;
|
||||
public IPublishedContent DraftModel;
|
||||
public IPublishedContent PublishedModel;
|
||||
|
||||
public ContentNode CloneParent(IPublishedSnapshotAccessor publishedSnapshotAccessor)
|
||||
{
|
||||
@@ -144,13 +151,13 @@ namespace Umbraco.Web.PublishedCache.NuCache
|
||||
|
||||
public ContentNodeKit ToKit()
|
||||
{
|
||||
var draft = Draft is PublishedContentModel draftModel
|
||||
var draft = DraftModel is PublishedContentModel draftModel
|
||||
? (PublishedContent) draftModel.Unwrap()
|
||||
: (PublishedContent) Draft;
|
||||
: (PublishedContent) DraftModel;
|
||||
|
||||
var published = Published is PublishedContentModel publishedModel
|
||||
var published = PublishedModel is PublishedContentModel publishedModel
|
||||
? (PublishedContent) publishedModel.Unwrap()
|
||||
: (PublishedContent) Published;
|
||||
: (PublishedContent) PublishedModel;
|
||||
|
||||
return new ContentNodeKit
|
||||
{
|
||||
|
||||
@@ -652,7 +652,7 @@ namespace Umbraco.Web.PublishedCache.NuCache
|
||||
return true;
|
||||
var link = GetParentLink(kit.Node);
|
||||
var node = link?.Value;
|
||||
return node?.Published != null;
|
||||
return node?.PublishedModel != null;
|
||||
}
|
||||
|
||||
private void AddToParentLocked(ContentNode content)
|
||||
|
||||
@@ -34,14 +34,14 @@ namespace Umbraco.Web.PublishedCache.NuCache
|
||||
{
|
||||
// ignore preview, there's only draft for media
|
||||
var n = _snapshot.Get(contentId);
|
||||
return n?.Published;
|
||||
return n?.PublishedModel;
|
||||
}
|
||||
|
||||
public override IPublishedContent GetById(bool preview, Guid contentId)
|
||||
{
|
||||
// ignore preview, there's only draft for media
|
||||
var n = _snapshot.Get(contentId);
|
||||
return n?.Published;
|
||||
return n?.PublishedModel;
|
||||
}
|
||||
|
||||
public override bool HasById(bool preview, int contentId)
|
||||
@@ -73,7 +73,7 @@ namespace Umbraco.Web.PublishedCache.NuCache
|
||||
var c = _snapshot.GetAtRoot();
|
||||
|
||||
// ignore preview, there's only draft for media
|
||||
return c.Select(n => n.Published);
|
||||
return c.Select(n => n.PublishedModel);
|
||||
}
|
||||
|
||||
public override bool HasContent(bool preview)
|
||||
|
||||
@@ -300,7 +300,7 @@ namespace Umbraco.Web.PublishedCache.NuCache
|
||||
// invariant content items)
|
||||
|
||||
// if there is no 'published' published content, no culture can be published
|
||||
var hasPublished = _contentNode.Published != null;
|
||||
var hasPublished = _contentNode.PublishedModel != null;
|
||||
if (!hasPublished)
|
||||
return false;
|
||||
|
||||
@@ -314,7 +314,7 @@ namespace Umbraco.Web.PublishedCache.NuCache
|
||||
|
||||
// there is a 'published' published content, and varies
|
||||
// = depends on the culture
|
||||
return ((PublishedContent) _contentNode.Published)._contentData.CultureInfos.ContainsKey(culture);
|
||||
return _contentNode.PublishedContent._contentData.CultureInfos.ContainsKey(culture);
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
Reference in New Issue
Block a user