Makes UmbracoContext disposable and fixes the module's DisposeHttpContextItems to actual perform the disposal of each item.
This commit is contained in:
@@ -24,7 +24,7 @@ namespace Umbraco.Web
|
||||
/// <summary>
|
||||
/// Class that encapsulates Umbraco information of a specific HTTP request
|
||||
/// </summary>
|
||||
public class UmbracoContext
|
||||
public class UmbracoContext : DisposableObject
|
||||
{
|
||||
private const string HttpContextItemName = "Umbraco.Web.UmbracoContext";
|
||||
private static readonly object Locker = new object();
|
||||
@@ -361,7 +361,17 @@ namespace Umbraco.Web
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
protected override void DisposeResources()
|
||||
{
|
||||
Security.DisposeIfDisposable();
|
||||
Security = null;
|
||||
_previewContent = null;
|
||||
_umbracoContext = null;
|
||||
//ensure not to dispose this!
|
||||
Application = null;
|
||||
ContentCache = null;
|
||||
MediaCache = null;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,4 +1,5 @@
|
||||
using System;
|
||||
using System.Collections;
|
||||
using System.IO;
|
||||
using System.Linq;
|
||||
using System.Web;
|
||||
@@ -166,23 +167,6 @@ namespace Umbraco.Web
|
||||
return end;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Checks if the xml cache file needs to be updated/persisted
|
||||
/// </summary>
|
||||
/// <param name="httpContext"></param>
|
||||
/// <remarks>
|
||||
/// TODO: This needs an overhaul, see the error report created here:
|
||||
/// https://docs.google.com/document/d/1neGE3q3grB4lVJfgID1keWY2v9JYqf-pw75sxUUJiyo/edit
|
||||
/// </remarks>
|
||||
void PersistXmlCache(HttpContextBase httpContext)
|
||||
{
|
||||
if (content.Instance.IsXmlQueuedForPersistenceToFile)
|
||||
{
|
||||
content.Instance.RemoveXmlFilePersistenceQueue();
|
||||
content.Instance.PersistXmlToFile();
|
||||
}
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region Route helper methods
|
||||
@@ -350,7 +334,7 @@ namespace Umbraco.Web
|
||||
/// </summary>
|
||||
/// <param name="context"></param>
|
||||
/// <param name="pcr"> </param>
|
||||
private void RewriteToUmbracoHandler(HttpContextBase context, PublishedContentRequest pcr)
|
||||
private static void RewriteToUmbracoHandler(HttpContextBase context, PublishedContentRequest pcr)
|
||||
{
|
||||
// NOTE: we do not want to use TransferRequest even though many docs say it is better with IIS7, turns out this is
|
||||
// not what we need. The purpose of TransferRequest is to ensure that .net processes all of the rules for the newly
|
||||
@@ -402,6 +386,36 @@ namespace Umbraco.Web
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Checks if the xml cache file needs to be updated/persisted
|
||||
/// </summary>
|
||||
/// <param name="httpContext"></param>
|
||||
/// <remarks>
|
||||
/// TODO: This needs an overhaul, see the error report created here:
|
||||
/// https://docs.google.com/document/d/1neGE3q3grB4lVJfgID1keWY2v9JYqf-pw75sxUUJiyo/edit
|
||||
/// </remarks>
|
||||
static void PersistXmlCache(HttpContextBase httpContext)
|
||||
{
|
||||
if (content.Instance.IsXmlQueuedForPersistenceToFile)
|
||||
{
|
||||
content.Instance.RemoveXmlFilePersistenceQueue();
|
||||
content.Instance.PersistXmlToFile();
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Any object that is in the HttpContext.Items collection that is IDisposable will get disposed on the end of the request
|
||||
/// </summary>
|
||||
/// <param name="http"></param>
|
||||
private static void DisposeHttpContextItems(HttpContext http)
|
||||
{
|
||||
foreach (DictionaryEntry i in http.Items)
|
||||
{
|
||||
i.Value.DisposeIfDisposable();
|
||||
i.Key.DisposeIfDisposable();
|
||||
}
|
||||
}
|
||||
|
||||
#region IHttpModule
|
||||
|
||||
/// <summary>
|
||||
@@ -469,18 +483,6 @@ namespace Umbraco.Web
|
||||
|
||||
#endregion
|
||||
|
||||
/// <summary>
|
||||
/// Any object that is in the HttpContext.Items collection that is IDisposable will get disposed on the end of the request
|
||||
/// </summary>
|
||||
/// <param name="http"></param>
|
||||
private static void DisposeHttpContextItems(HttpContext http)
|
||||
{
|
||||
foreach(var i in http.Items)
|
||||
{
|
||||
i.DisposeIfDisposable();
|
||||
}
|
||||
}
|
||||
|
||||
#region Events
|
||||
internal static event EventHandler<RoutableAttemptEventArgs> RouteAttempt;
|
||||
private void OnRouteAttempt(RoutableAttemptEventArgs args)
|
||||
|
||||
Reference in New Issue
Block a user