Fixed XmlDocument GetProperty to check for user properties 'invariantly'.

Added a method on content to remove the file persistence queue just before it's written based on the module, this should hopefully speed things up and fix some potential issues.
Added an overloaded method on library for UpdateDocumentCache which should save on a few dozen sql calls when publishing a node since we already have
the Document object reference yet we were looking it up again for no reason.
This commit is contained in:
Shannon Deminick
2012-09-02 07:35:57 +07:00
parent a293f53438
commit 2fc0fe574b
5 changed files with 41 additions and 13 deletions

View File

@@ -5,6 +5,7 @@ using System.Linq;
using System.Xml;
using System.Xml.Serialization;
using System.Xml.XPath;
using Umbraco.Core;
using Umbraco.Core.Configuration;
using Umbraco.Core.Models;
@@ -263,7 +264,7 @@ namespace Umbraco.Web.Models
public IDocumentProperty GetProperty(string alias)
{
return Properties.FirstOrDefault(p => p.Alias == alias);
return Properties.FirstOrDefault(p => p.Alias.InvariantEquals(alias));
}
private void InitializeStructure()

View File

@@ -164,6 +164,7 @@ namespace Umbraco.Web
{
if (content.Instance.IsXmlQueuedForPersistenceToFile)
{
content.Instance.RemoveXmlFilePersistenceQueue();
content.Instance.PersistXmlToFile();
}
}

View File

@@ -896,6 +896,16 @@ namespace umbraco
internal const string PersistenceFlagContextKey = "vnc38ykjnkjdnk2jt98ygkxjng";
/// <summary>
/// Removes the flag that queues the file for persistence
/// </summary>
internal void RemoveXmlFilePersistenceQueue()
{
HttpContext.Current.Application.Lock();
HttpContext.Current.Application[PersistenceFlagContextKey] = null;
HttpContext.Current.Application.UnLock();
}
internal bool IsXmlQueuedForPersistenceToFile
{
get
@@ -915,9 +925,7 @@ namespace umbraco
}
else
{
HttpContext.Current.Application.Lock();
HttpContext.Current.Application[PersistenceFlagContextKey] = null;
HttpContext.Current.Application.UnLock();
RemoveXmlFilePersistenceQueue();
}
}
catch

View File

@@ -191,17 +191,33 @@ namespace umbraco
/// 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.
/// </summary>
/// <param name="DocumentId">The Id of the Document to be published</param>
public static void UpdateDocumentCache(int DocumentId)
/// <param name="documentId">The Id of the Document to be published</param>
public static void UpdateDocumentCache(int documentId)
{
if (UmbracoSettings.UseDistributedCalls)
dispatcher.Refresh(
new Guid("27ab3022-3dfa-47b6-9119-5945bc88fd66"),
DocumentId);
else
content.Instance.UpdateDocumentCache(DocumentId);
var d = new Document(documentId);
UpdateDocumentCache(d);
}
/// <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.
/// </summary>
/// <param name="doc"></param>
/// <remarks>
/// NOTE: This method was created because before it was always calling the method with the documentId as a parameter
/// 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)
{
if (UmbracoSettings.UseDistributedCalls)
dispatcher.Refresh(
new Guid("27ab3022-3dfa-47b6-9119-5945bc88fd66"),
doc.Id);
else
content.Instance.UpdateDocumentCache(doc);
}
/// <summary>
/// Publishes the single node, this method is obsolete
@@ -1563,6 +1579,8 @@ namespace umbraco
}
}
//TODO: WTF, why is this here? This won't matter if there's an UmbracoContext or not, it will call the same underlying method!
// only difference is that the UmbracoContext way will check if its in preview mode.
private static XmlDocument GetThreadsafeXmlDocument()
{
return UmbracoContext.Current != null

View File

@@ -315,7 +315,7 @@ namespace umbraco.cms.presentation
{
ClientTools.ShowSpeechBubble(speechBubbleIcon.save, ui.Text("speechBubbles", "editContentPublishedHeader", null), ui.Text("speechBubbles", "editContentPublishedText", null));
library.UpdateDocumentCache(_document.Id);
library.UpdateDocumentCache(_document);
BusinessLogic.Log.Add(BusinessLogic.LogTypes.Publish, base.getUser(), _document.Id, "");
littPublishStatus.Text = ui.Text("content", "lastPublished", base.getUser()) + ": " + _document.VersionDate.ToString() + "<br/>";