Fixes: U4-5388 YSOD after doctype rename & U4-5387 Deleting Properties in document types causes "Object reference not set to an instance of an object"

This commit is contained in:
Shannon
2014-08-25 16:13:21 +10:00
parent 45f44e1797
commit 4cec6a3213

View File

@@ -21,6 +21,7 @@ using umbraco.cms.businesslogic.cache;
using umbraco.cms.businesslogic.web;
using umbraco.DataLayer;
using umbraco.presentation.nodeFactory;
using Umbraco.Web;
using Action = umbraco.BusinessLogic.Actions.Action;
using Node = umbraco.NodeFactory.Node;
using Umbraco.Core;
@@ -97,13 +98,13 @@ namespace umbraco
{
get
{
if (HttpContext.Current == null)
if (UmbracoContext.Current == null || UmbracoContext.Current.HttpContext == null)
return XmlContentInternal;
var content = HttpContext.Current.Items[XmlContextContentItemKey] as XmlDocument;
var content = UmbracoContext.Current.HttpContext.Items[XmlContextContentItemKey] as XmlDocument;
if (content == null)
{
content = XmlContentInternal;
HttpContext.Current.Items[XmlContextContentItemKey] = content;
UmbracoContext.Current.HttpContext.Items[XmlContextContentItemKey] = content;
}
return content;
}
@@ -828,24 +829,27 @@ namespace umbraco
/// </summary>
internal void RemoveXmlFilePersistenceQueue()
{
HttpContext.Current.Application.Lock();
HttpContext.Current.Application[PersistenceFlagContextKey] = null;
HttpContext.Current.Application.UnLock();
if (UmbracoContext.Current != null && UmbracoContext.Current.HttpContext != null)
{
UmbracoContext.Current.HttpContext.Application.Lock();
UmbracoContext.Current.HttpContext.Application[PersistenceFlagContextKey] = null;
UmbracoContext.Current.HttpContext.Application.UnLock();
}
}
internal bool IsXmlQueuedForPersistenceToFile
{
get
{
if (HttpContext.Current != null)
if (UmbracoContext.Current != null && UmbracoContext.Current.HttpContext != null)
{
bool val = HttpContext.Current.Application[PersistenceFlagContextKey] != null;
bool val = UmbracoContext.Current.HttpContext.Application[PersistenceFlagContextKey] != null;
if (val)
{
DateTime persistenceTime = DateTime.MinValue;
try
{
persistenceTime = (DateTime)HttpContext.Current.Application[PersistenceFlagContextKey];
persistenceTime = (DateTime)UmbracoContext.Current.HttpContext.Application[PersistenceFlagContextKey];
if (persistenceTime > GetCacheFileUpdateTime())
{
return true;
@@ -894,8 +898,8 @@ namespace umbraco
private void ClearContextCache()
{
// If running in a context very important to reset context cache orelse new nodes are missing
if (HttpContext.Current != null && HttpContext.Current.Items.Contains(XmlContextContentItemKey))
HttpContext.Current.Items.Remove(XmlContextContentItemKey);
if (UmbracoContext.Current != null && UmbracoContext.Current.HttpContext != null && UmbracoContext.Current.HttpContext.Items.Contains(XmlContextContentItemKey))
UmbracoContext.Current.HttpContext.Items.Remove(XmlContextContentItemKey);
}
/// <summary>
@@ -1193,20 +1197,20 @@ order by umbracoNode.level, umbracoNode.sortOrder";
{
//if this is called outside a web request we cannot queue it it will run in the current thread.
if (HttpContext.Current != null)
if (UmbracoContext.Current != null && UmbracoContext.Current.HttpContext != null)
{
HttpContext.Current.Application.Lock();
UmbracoContext.Current.HttpContext.Application.Lock();
try
{
if (HttpContext.Current.Application[PersistenceFlagContextKey] != null)
if (UmbracoContext.Current.HttpContext.Application[PersistenceFlagContextKey] != null)
{
HttpContext.Current.Application.Add(PersistenceFlagContextKey, null);
UmbracoContext.Current.HttpContext.Application.Add(PersistenceFlagContextKey, null);
}
HttpContext.Current.Application[PersistenceFlagContextKey] = DateTime.UtcNow;
UmbracoContext.Current.HttpContext.Application[PersistenceFlagContextKey] = DateTime.UtcNow;
}
finally
{
HttpContext.Current.Application.UnLock();
UmbracoContext.Current.HttpContext.Application.UnLock();
}
}
else