Skip to content
This repository has been archived by the owner on Feb 10, 2024. It is now read-only.

Commit

Permalink
Merge pull request #31 from nvisage-gf/develop
Browse files Browse the repository at this point in the history
Workaround for null issues when indexing
  • Loading branch information
leekelleher committed Oct 24, 2015
2 parents 5aacebb + 9e4b481 commit c45989e
Showing 1 changed file with 13 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -27,9 +27,19 @@ public static IPublishedContent ConvertValueToContent(string id, string docTypeA
if (string.IsNullOrWhiteSpace(docTypeAlias))
return null;

if (UmbracoContext.Current != null)
{
return (IPublishedContent)ApplicationContext.Current.ApplicationCache.RequestCache.GetCacheItem(
"DocTypeGridEditorHelper.ConvertValueToContent_" + id + "_" + docTypeAlias, () =>
{
return ConvertValue(id, docTypeAlias, dataJson);
});
}
return (IPublishedContent) ConvertValue(id, docTypeAlias, dataJson);
}

private static IPublishedContent ConvertValue(string id, string docTypeAlias, string dataJson)
{
using (var timer = DisposableTimer.DebugDuration<DocTypeGridEditorHelper>(string.Format("ConvertValueToContent ({0}, {1})", id, docTypeAlias)))
{
Guid docTypeGuid;
Expand Down Expand Up @@ -83,15 +93,15 @@ public static IPublishedContent ConvertValueToContent(string id, string docTypeA
}

// Get the current request node we are embedded in
var pcr = UmbracoContext.Current.PublishedContentRequest;
var pcr = UmbracoContext.Current == null ? null : UmbracoContext.Current.PublishedContentRequest;
var containerNode = pcr != null && pcr.HasPublishedContent ? pcr.PublishedContent : null;

return new DetachedPublishedContent(nameObj == null ? null : nameObj.ToString(),
publishedContentType,
properties.ToArray(),
containerNode);
}
});

}
}
}
}

0 comments on commit c45989e

Please sign in to comment.