Need to refactor IsPublished
This commit is contained in:
@@ -156,10 +156,17 @@ namespace Umbraco.Core.Models.PublishedContent
|
||||
/// <summary>
|
||||
/// Gets a value indicating whether the content is published.
|
||||
/// </summary>
|
||||
/// <param name="culture"></param>
|
||||
/// <remarks>
|
||||
/// <para>A content is published when it has a published version.</para>
|
||||
/// <para>When retrieving documents from cache in non-preview mode, IsPublished is always
|
||||
/// true, as only published documents are returned. When retrieving in draft mode, IsPublished
|
||||
/// can either be true (document has a published version) or false (document has no
|
||||
/// published version).</para>
|
||||
/// <para>It is therefore possible for both IsDraft and IsPublished to be true at the same
|
||||
/// time, meaning that the content is the draft version, and a published version exists.</para>
|
||||
/// </remarks>
|
||||
bool IsPublished(string culture = null);
|
||||
|
||||
|
||||
#endregion
|
||||
|
||||
#region Tree
|
||||
|
||||
@@ -114,7 +114,6 @@ namespace Umbraco.Core.Models.PublishedContent
|
||||
/// <inheritdoc />
|
||||
public virtual bool IsPublished(string culture = null) => _content.IsPublished(culture);
|
||||
|
||||
|
||||
#endregion
|
||||
|
||||
#region Tree
|
||||
|
||||
@@ -144,6 +144,7 @@ namespace Umbraco.Web.Models
|
||||
/// <inheritdoc />
|
||||
public abstract bool IsDraft(string culture = null);
|
||||
|
||||
/// <inheritdoc />
|
||||
public abstract bool IsPublished(string culture = null);
|
||||
|
||||
#endregion
|
||||
|
||||
@@ -293,8 +293,11 @@ namespace Umbraco.Web.PublishedCache.NuCache
|
||||
return _contentData.CultureInfos.TryGetValue(culture, out var cvar) && cvar.IsDraft;
|
||||
}
|
||||
|
||||
/// <inheritdoc />
|
||||
public override bool IsPublished(string culture = null)
|
||||
{
|
||||
// fixme I don't understand this - and it does probably not do what's expected
|
||||
|
||||
if (!ContentType.VariesByCulture())
|
||||
{
|
||||
return _contentData.Published;
|
||||
@@ -302,9 +305,7 @@ namespace Umbraco.Web.PublishedCache.NuCache
|
||||
|
||||
// handle context culture
|
||||
if (culture == null)
|
||||
{
|
||||
culture = VariationContextAccessor?.VariationContext?.Culture ?? "";
|
||||
}
|
||||
|
||||
//If the current culture is not a draft, it must be the published version
|
||||
return _contentData.CultureInfos.TryGetValue(culture, out var cvar) && !cvar.IsDraft;
|
||||
|
||||
@@ -232,7 +232,7 @@ namespace Umbraco.Web.PublishedCache.XmlPublishedCache
|
||||
public override bool IsPublished(string culture = null)
|
||||
{
|
||||
EnsureNodeInitialized();
|
||||
return _isPublished;
|
||||
return _isPublished; // bah
|
||||
}
|
||||
|
||||
public override IEnumerable<IPublishedProperty> Properties
|
||||
@@ -309,7 +309,7 @@ namespace Umbraco.Web.PublishedCache.XmlPublishedCache
|
||||
name = writerName = urlName = creatorName = docTypeAlias = path = null;
|
||||
createDate = updateDate = default(DateTime);
|
||||
isDraft = false;
|
||||
isPublished = false;
|
||||
isPublished = false; // fixme not implemented?
|
||||
contentType = null;
|
||||
properties = null;
|
||||
|
||||
|
||||
Reference in New Issue
Block a user