Updates all code calling UnPublishSingleNode & UpdateDocumentCache to pass in the already existing Document object if there is one
instead of the ID... this'll save a another ton of SQL calls.
This commit is contained in:
@@ -580,40 +580,42 @@ namespace umbraco
|
||||
ThreadPool.QueueUserWorkItem(delegate { UpdateDocumentCache(documentId); });
|
||||
}
|
||||
|
||||
|
||||
[Obsolete("Method obsolete in version 4.1 and later, please use ClearDocumentCache", true)]
|
||||
/// <summary>
|
||||
/// Clears the document cache async.
|
||||
/// </summary>
|
||||
/// <param name="documentId">The document id.</param>
|
||||
[Obsolete("Method obsolete in version 4.1 and later, please use ClearDocumentCache", true)]
|
||||
public virtual void ClearDocumentCacheAsync(int documentId)
|
||||
{
|
||||
ThreadPool.QueueUserWorkItem(delegate { ClearDocumentCache(documentId); });
|
||||
}
|
||||
|
||||
public virtual void ClearDocumentCache(int documentId)
|
||||
{
|
||||
// Get the document
|
||||
var d = new Document(documentId);
|
||||
ClearDocumentCache(d);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Clears the document cache and removes the document from the xml db cache.
|
||||
/// This means the node gets unpublished from the website.
|
||||
/// </summary>
|
||||
/// <param name="documentId">The document id.</param>
|
||||
public virtual void ClearDocumentCache(int documentId)
|
||||
/// <param name="doc">The document</param>
|
||||
public virtual void ClearDocumentCache(Document doc)
|
||||
{
|
||||
// Get the document
|
||||
var d = new Document(documentId);
|
||||
|
||||
var e = new DocumentCacheEventArgs();
|
||||
FireBeforeClearDocumentCache(d, e);
|
||||
FireBeforeClearDocumentCache(doc, e);
|
||||
|
||||
if (!e.Cancel)
|
||||
{
|
||||
XmlNode x;
|
||||
|
||||
// remove from xml db cache
|
||||
d.XmlRemoveFromDB();
|
||||
doc.XmlRemoveFromDB();
|
||||
|
||||
// Check if node present, before cloning
|
||||
x = XmlContentInternal.GetElementById(d.Id.ToString());
|
||||
x = XmlContentInternal.GetElementById(doc.Id.ToString());
|
||||
if (x == null)
|
||||
return;
|
||||
|
||||
@@ -626,7 +628,7 @@ namespace umbraco
|
||||
XmlDocument xmlContentCopy = CloneXmlDoc(XmlContentInternal);
|
||||
|
||||
// Find the document in the xml cache
|
||||
x = xmlContentCopy.GetElementById(d.Id.ToString());
|
||||
x = xmlContentCopy.GetElementById(doc.Id.ToString());
|
||||
if (x != null)
|
||||
{
|
||||
// The document already exists in cache, so repopulate it
|
||||
@@ -639,17 +641,17 @@ namespace umbraco
|
||||
if (x != null)
|
||||
{
|
||||
// Run Handler
|
||||
Action.RunActionHandlers(d, ActionUnPublish.Instance);
|
||||
Action.RunActionHandlers(doc, ActionUnPublish.Instance);
|
||||
}
|
||||
|
||||
// update sitemapprovider
|
||||
if (SiteMap.Provider is UmbracoSiteMapProvider)
|
||||
{
|
||||
var prov = (UmbracoSiteMapProvider)SiteMap.Provider;
|
||||
prov.RemoveNode(d.Id);
|
||||
prov.RemoveNode(doc.Id);
|
||||
}
|
||||
|
||||
FireAfterClearDocumentCache(d, e);
|
||||
FireAfterClearDocumentCache(doc, e);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -187,9 +187,7 @@ namespace umbraco
|
||||
/// </summary>
|
||||
/// <param name="DocumentId">The Id of the Document to be unpublished</param>
|
||||
public static void UnPublishSingleNode(int DocumentId)
|
||||
{
|
||||
|
||||
//PPH Added dispatcher support
|
||||
{
|
||||
if (UmbracoSettings.UseDistributedCalls)
|
||||
dispatcher.Remove(
|
||||
new Guid("27ab3022-3dfa-47b6-9119-5945bc88fd66"),
|
||||
@@ -198,6 +196,21 @@ namespace umbraco
|
||||
content.Instance.ClearDocumentCache(DocumentId);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Unpublish a node, by removing it from the runtime xml index. Note, prior to this the Document should be
|
||||
/// marked unpublished by setting the publish property on the document object to false
|
||||
/// </summary>
|
||||
/// <param name="document">The Document to be unpublished</param>
|
||||
public static void UnPublishSingleNode(Document document)
|
||||
{
|
||||
if (UmbracoSettings.UseDistributedCalls)
|
||||
dispatcher.Remove(
|
||||
new Guid("27ab3022-3dfa-47b6-9119-5945bc88fd66"),
|
||||
document.Id);
|
||||
else
|
||||
content.Instance.ClearDocumentCache(document);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Publishes a Document by adding it to the runtime xml index. Note, prior to this the Document should be
|
||||
/// marked published by calling Publish(User u) on the document object.
|
||||
@@ -219,7 +232,7 @@ namespace umbraco
|
||||
/// which means we have to re-look up the document in the db again when we already have it, this should save on a few
|
||||
/// dozen sql calls when publishing.
|
||||
/// </remarks>
|
||||
internal static void UpdateDocumentCache(Document doc)
|
||||
public static void UpdateDocumentCache(Document doc)
|
||||
{
|
||||
if (UmbracoSettings.UseDistributedCalls)
|
||||
dispatcher.Refresh(
|
||||
|
||||
@@ -38,7 +38,7 @@ namespace umbraco.presentation
|
||||
d.ReleaseDate = DateTime.MinValue; //new DateTime(1, 1, 1); // Causes release date to be null
|
||||
|
||||
d.Publish(d.User);
|
||||
library.UpdateDocumentCache(d.Id);
|
||||
library.UpdateDocumentCache(d);
|
||||
|
||||
}
|
||||
catch(Exception ee)
|
||||
|
||||
+1
-1
@@ -132,7 +132,7 @@ namespace umbraco.presentation.LiveEditing.Modules.CreateModule
|
||||
DocumentType typeToCreate = new DocumentType(Convert.ToInt32(m_AllowedDocTypesDropdown.SelectedValue));
|
||||
Document newDoc = Document.MakeNew(m_NameTextBox.Text, typeToCreate, new global::umbraco.BusinessLogic.User(userid), (int)UmbracoContext.Current.PageId);
|
||||
newDoc.Publish(new global::umbraco.BusinessLogic.User(userid));
|
||||
library.UpdateDocumentCache(newDoc.Id);
|
||||
library.UpdateDocumentCache(newDoc);
|
||||
Page.Response.Redirect(library.NiceUrl(newDoc.Id), false);
|
||||
break;
|
||||
}
|
||||
|
||||
@@ -39,7 +39,7 @@ namespace umbraco.presentation.actions
|
||||
|
||||
confirm.Visible = false;
|
||||
d.Publish(getUser());
|
||||
library.UpdateDocumentCache(d.Id);
|
||||
library.UpdateDocumentCache(d);
|
||||
|
||||
deleted.Text = ui.Text("editContentPublishedHeader") + " ('" + d.Text + "') " + ui.Text("editContentPublishedText") + "</p><p><a href=\"" + library.NiceUrl(d.Id) + "\"> " + ui.Text("view") + " " + d.Text + "</a>";
|
||||
}
|
||||
|
||||
@@ -84,7 +84,7 @@ namespace umbraco.presentation.channels
|
||||
if (publish)
|
||||
{
|
||||
doc.Publish(new User(username));
|
||||
library.UpdateDocumentCache(doc.Id);
|
||||
library.UpdateDocumentCache(doc);
|
||||
}
|
||||
return true;
|
||||
}
|
||||
@@ -403,7 +403,7 @@ namespace umbraco.presentation.channels
|
||||
if (publish)
|
||||
{
|
||||
doc.Publish(new User(username));
|
||||
library.UpdateDocumentCache(doc.Id);
|
||||
library.UpdateDocumentCache(doc);
|
||||
}
|
||||
return doc.Id.ToString();
|
||||
}
|
||||
|
||||
@@ -152,7 +152,7 @@ namespace umbraco.dialogs
|
||||
if (cd.Published) {
|
||||
cd.Publish(new umbraco.BusinessLogic.User(0));
|
||||
//using library.publish to support load balancing.
|
||||
umbraco.library.UpdateDocumentCache(cd.Id);
|
||||
umbraco.library.UpdateDocumentCache(cd);
|
||||
|
||||
|
||||
if (cd.HasChildren) {
|
||||
@@ -299,7 +299,7 @@ namespace umbraco.dialogs
|
||||
d.Publish(new umbraco.BusinessLogic.User(0));
|
||||
//using library.publish to support load balancing.
|
||||
//umbraco.library.PublishSingleNode(d.Id);
|
||||
umbraco.library.UpdateDocumentCache(d.Id);
|
||||
umbraco.library.UpdateDocumentCache(d);
|
||||
|
||||
//PPH added handling of load balanced moving of multiple nodes...
|
||||
if (d.HasChildren)
|
||||
|
||||
@@ -92,7 +92,7 @@ namespace umbraco.dialogs
|
||||
{
|
||||
if (doc.Published)
|
||||
{
|
||||
library.UpdateDocumentCache(doc.Id);
|
||||
library.UpdateDocumentCache(doc);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -116,7 +116,7 @@ namespace umbraco.dialogs
|
||||
{
|
||||
if (d.PublishWithResult(base.getUser()))
|
||||
{
|
||||
library.UpdateDocumentCache(d.Id);
|
||||
library.UpdateDocumentCache(d);
|
||||
feedbackMsg.type = umbraco.uicontrols.Feedback.feedbacktype.success;
|
||||
feedbackMsg.Text = ui.Text("publish", "nodePublish", d.Text, base.getUser()) + "</p><p><a href='#' onclick='" + ClientTools.Scripts.CloseModalWindow() + "'>" + ui.Text("closeThisWindow") + "</a>";
|
||||
}
|
||||
@@ -141,7 +141,7 @@ namespace umbraco.dialogs
|
||||
{
|
||||
// Needed for supporting distributed calls
|
||||
if (UmbracoSettings.UseDistributedCalls)
|
||||
library.UpdateDocumentCache(d.Id);
|
||||
library.UpdateDocumentCache(d);
|
||||
else
|
||||
documents.Add(d);
|
||||
|
||||
|
||||
@@ -250,7 +250,7 @@ namespace umbraco
|
||||
}
|
||||
}
|
||||
|
||||
library.UpdateDocumentCache(document.Id);
|
||||
library.UpdateDocumentCache(document);
|
||||
|
||||
return document;
|
||||
}
|
||||
|
||||
@@ -246,13 +246,13 @@ namespace umbraco.webservices.documents
|
||||
case documentCarrier.EPublishAction.Publish:
|
||||
if (doc.PublishWithResult(user))
|
||||
{
|
||||
umbraco.library.UpdateDocumentCache(doc.Id);
|
||||
umbraco.library.UpdateDocumentCache(doc);
|
||||
}
|
||||
break;
|
||||
case documentCarrier.EPublishAction.Unpublish:
|
||||
if (doc.PublishWithResult(user))
|
||||
{
|
||||
umbraco.library.UnPublishSingleNode(doc.Id);
|
||||
umbraco.library.UnPublishSingleNode(doc);
|
||||
}
|
||||
break;
|
||||
case documentCarrier.EPublishAction.Ignore:
|
||||
@@ -260,14 +260,14 @@ namespace umbraco.webservices.documents
|
||||
{
|
||||
if (doc.PublishWithResult(user))
|
||||
{
|
||||
umbraco.library.UpdateDocumentCache(doc.Id);
|
||||
umbraco.library.UpdateDocumentCache(doc);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
if (doc.PublishWithResult(user))
|
||||
{
|
||||
umbraco.library.UpdateDocumentCache(doc.Id);
|
||||
umbraco.library.UpdateDocumentCache(doc);
|
||||
}
|
||||
}
|
||||
break;
|
||||
|
||||
Reference in New Issue
Block a user