From ff6ee360da24231d6edd801e7fd1a9f2a5a4ae1a Mon Sep 17 00:00:00 2001 From: Stephan Date: Thu, 4 Apr 2013 15:24:29 -0200 Subject: [PATCH] ItemRenderer - cleanup access to Xml cache --- .../umbraco/templateControls/ItemRenderer.cs | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/src/Umbraco.Web/umbraco.presentation/umbraco/templateControls/ItemRenderer.cs b/src/Umbraco.Web/umbraco.presentation/umbraco/templateControls/ItemRenderer.cs index 01a321d899..e3303d2823 100644 --- a/src/Umbraco.Web/umbraco.presentation/umbraco/templateControls/ItemRenderer.cs +++ b/src/Umbraco.Web/umbraco.presentation/umbraco/templateControls/ItemRenderer.cs @@ -104,8 +104,9 @@ namespace umbraco.presentation.templateControls if (tempNodeId != null && tempNodeId.Value != 0) { //moved the following from the catch block up as this will allow fallback options alt text etc to work - var xml = ((PublishedContentCache) PublishedContentCacheResolver.Current.ContentCache) - .GetXml(Umbraco.Web.UmbracoContext.Current); + var cache = Umbraco.Web.UmbracoContext.Current.ContentCache.InnerCache as PublishedContentCache; + if (cache == null) throw new InvalidOperationException("Unsupported IPublishedContentCache, only the Xml one is supported."); + var xml = cache.GetXml(Umbraco.Web.UmbracoContext.Current); var itemPage = new page(xml.GetElementById(tempNodeId.ToString())); tempElementContent = new item(itemPage.Elements, item.LegacyAttributes).FieldContent; }