From dfbdf99bbc066bbd39f69762b9137d3e09454ff2 Mon Sep 17 00:00:00 2001 From: Stephan Date: Tue, 1 Sep 2015 14:49:50 +0200 Subject: [PATCH] U4-7038 - IPublishedContentWithKey for medias --- .../XmlPublishedCache/PublishedMediaCache.cs | 15 +++++++++++++-- src/UmbracoExamine/UmbracoContentIndexer.cs | 1 + 2 files changed, 14 insertions(+), 2 deletions(-) diff --git a/src/Umbraco.Web/PublishedCache/XmlPublishedCache/PublishedMediaCache.cs b/src/Umbraco.Web/PublishedCache/XmlPublishedCache/PublishedMediaCache.cs index 2e437ccc97..61dd50e610 100644 --- a/src/Umbraco.Web/PublishedCache/XmlPublishedCache/PublishedMediaCache.cs +++ b/src/Umbraco.Web/PublishedCache/XmlPublishedCache/PublishedMediaCache.cs @@ -273,6 +273,10 @@ namespace Umbraco.Web.PublishedCache.XmlPublishedCache values.Add("level", values["__Path"].Split(',').Length.ToString()); } + // because, migration + if (values.ContainsKey("key") == false) + values["key"] = Guid.Empty.ToString(); + return new CacheValues { Values = values, @@ -321,6 +325,9 @@ namespace Umbraco.Web.PublishedCache.XmlPublishedCache result.Current.MoveToParent(); } } + // because, migration + if (values.ContainsKey("key") == false) + values["key"] = Guid.Empty.ToString(); //add the user props while (result.MoveNext()) { @@ -526,7 +533,7 @@ namespace Umbraco.Web.PublishedCache.XmlPublishedCache /// This is a helper class and definitely not intended for public use, it expects that all of the values required /// to create an IPublishedContent exist in the dictionary by specific aliases. /// - internal class DictionaryPublishedContent : PublishedContentBase + internal class DictionaryPublishedContent : PublishedContentWithKeyBase { // note: I'm not sure this class fully complies with IPublishedContent rules especially // I'm not sure that _properties contains all properties including those without a value, @@ -534,7 +541,7 @@ namespace Umbraco.Web.PublishedCache.XmlPublishedCache // List of properties that will appear in the XML and do not match // anything in the ContentType, so they must be ignored. - private static readonly string[] IgnoredKeys = { "version", "isDoc", "key" }; + private static readonly string[] IgnoredKeys = { "version", "isDoc" }; public DictionaryPublishedContent( IDictionary valueDictionary, @@ -555,6 +562,7 @@ namespace Umbraco.Web.PublishedCache.XmlPublishedCache LoadedFromExamine = fromExamine; ValidateAndSetProperty(valueDictionary, val => _id = int.Parse(val), "id", "nodeId", "__NodeId"); //should validate the int! + ValidateAndSetProperty(valueDictionary, val => _key = Guid.Parse(val), "key"); // wtf are we dealing with templates for medias?! ValidateAndSetProperty(valueDictionary, val => _templateId = int.Parse(val), "template", "templateId"); ValidateAndSetProperty(valueDictionary, val => _sortOrder = int.Parse(val), "sortOrder"); @@ -664,6 +672,8 @@ namespace Umbraco.Web.PublishedCache.XmlPublishedCache get { return _id; } } + public override Guid Key { get { return _key; } } + public override int TemplateId { get @@ -803,6 +813,7 @@ namespace Umbraco.Web.PublishedCache.XmlPublishedCache private readonly List _keysAdded = new List(); private int _id; + private Guid _key; private int _templateId; private int _sortOrder; private string _name; diff --git a/src/UmbracoExamine/UmbracoContentIndexer.cs b/src/UmbracoExamine/UmbracoContentIndexer.cs index de76ab8e79..613304c4ff 100644 --- a/src/UmbracoExamine/UmbracoContentIndexer.cs +++ b/src/UmbracoExamine/UmbracoContentIndexer.cs @@ -145,6 +145,7 @@ namespace UmbracoExamine = new List { new StaticField("id", FieldIndexTypes.NOT_ANALYZED, false, string.Empty), + new StaticField("key", FieldIndexTypes.NOT_ANALYZED, false, string.Empty), new StaticField( "version", FieldIndexTypes.NOT_ANALYZED, false, string.Empty), new StaticField( "parentID", FieldIndexTypes.NOT_ANALYZED, false, string.Empty), new StaticField( "level", FieldIndexTypes.NOT_ANALYZED, true, "NUMBER"),