From a88637910f04d0072da93f364c197bd2ca7b7bb3 Mon Sep 17 00:00:00 2001 From: Shannon Date: Thu, 10 Jul 2014 10:45:26 +1000 Subject: [PATCH] updates content xml bits so if it's called outside a web req it still executes. Conflicts: src/Umbraco.Web/umbraco.presentation/content.cs --- .../umbraco.presentation/content.cs | 24 +++++++++++++++---- 1 file changed, 19 insertions(+), 5 deletions(-) diff --git a/src/Umbraco.Web/umbraco.presentation/content.cs b/src/Umbraco.Web/umbraco.presentation/content.cs index 78a5fe7023..6b3cd50a9f 100644 --- a/src/Umbraco.Web/umbraco.presentation/content.cs +++ b/src/Umbraco.Web/umbraco.presentation/content.cs @@ -309,11 +309,12 @@ namespace umbraco XmlContentInternal = xmlDoc; // It is correct to manually call PersistXmlToFile here event though the setter of XmlContentInternal - // queues this up, because this delegate is executing on a different thread and may complete - // after the request which invoked it (which would normally persist the file on completion) - // So we are responsible for ensuring the content is persisted in this case. + // queues this up, because it is possible that this method gets called outside of a web context and in that + // case the queue is not going to be executed by the UmbracoModule. So we'll process inline on this thread + // and clear the queue in case is this a web request, we don't want it reprocessing. if (!UmbracoSettings.isXmlContentCacheDisabled && UmbracoSettings.continouslyUpdateXmlDiskCache) { + RemoveXmlFilePersistenceQueue(); PersistXmlToFile(xmlDoc); } } @@ -1189,7 +1190,7 @@ order by umbracoNode.level, umbracoNode.sortOrder"; /// private void QueueXmlForPersistence() { - //if this is called outside a web request we cannot queue it. + //if this is called outside a web request we cannot queue it it will run in the current thread. if (HttpContext.Current != null) { @@ -1206,7 +1207,20 @@ order by umbracoNode.level, umbracoNode.sortOrder"; { HttpContext.Current.Application.UnLock(); } - } + } + else + { + // Save copy of content + if (UmbracoSettings.CloneXmlCacheOnPublish) + { + XmlDocument xmlContentCopy = CloneXmlDoc(_xmlContent); + PersistXmlToFile(xmlContentCopy); + } + else + { + PersistXmlToFile(); + } + } } internal DateTime GetCacheFileUpdateTime()