Ensure entities type in content caches GetById(Udi)

This commit is contained in:
Stephan
2019-04-12 15:34:06 +02:00
parent 7f7c9d2796
commit 14f9445ffb
3 changed files with 15 additions and 1 deletions

View File

@@ -106,11 +106,19 @@ namespace Umbraco.Web.PublishedCache
{
var guidUdi = contentId as GuidUdi;
if (guidUdi == null)
throw new InvalidOperationException("UDIs for content items must be " + typeof(GuidUdi));
throw new ArgumentException($"Udi must be of type {typeof(GuidUdi).Name}.", nameof(contentId));
if (guidUdi.EntityType != UdiEntityType)
throw new ArgumentException($"Udi entity type must be \"{UdiEntityType}\".", nameof(contentId));
return GetById(preview, guidUdi.Guid);
}
/// <summary>
/// Gets the entity type.
/// </summary>
protected abstract string UdiEntityType { get; }
/// <summary>
/// Gets content at root.
/// </summary>

View File

@@ -2,6 +2,7 @@
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Umbraco.Core;
using Umbraco.Core.Models;
using Umbraco.Web.PublishedCache.XmlPublishedCache;
@@ -21,6 +22,8 @@ namespace Umbraco.Web.PublishedCache
: base(umbracoContext, cache)
{ }
protected override string UdiEntityType => Constants.UdiEntityType.Document;
public override IPublishedContent GetById(bool preview, Guid contentKey)
{
if (InnerCache is PublishedContentCache cc)

View File

@@ -2,6 +2,7 @@
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Umbraco.Core;
using Umbraco.Core.Models;
using Umbraco.Web.PublishedCache.XmlPublishedCache;
@@ -21,6 +22,8 @@ namespace Umbraco.Web.PublishedCache
: base(umbracoContext, cache)
{ }
protected override string UdiEntityType => Constants.UdiEntityType.Media;
public override IPublishedContent GetById(bool preview, Guid contentKey)
{
if (InnerCache is PublishedMediaCache cc)