From 1dd0086eb59e42d8566cc40415dae1eef94afc5a Mon Sep 17 00:00:00 2001 From: Stephan Date: Sat, 31 Oct 2015 12:46:26 +0100 Subject: [PATCH] Revert "strange/crazy peta poco fix for cultures" This reverts commit 0d29e1438cca7a2bd1bce19d6824931acb066d99. --- src/Umbraco.Core/Persistence/PetaPoco.cs | 51 +----------------------- 1 file changed, 2 insertions(+), 49 deletions(-) diff --git a/src/Umbraco.Core/Persistence/PetaPoco.cs b/src/Umbraco.Core/Persistence/PetaPoco.cs index 916f187b5b..d55ad8fc14 100644 --- a/src/Umbraco.Core/Persistence/PetaPoco.cs +++ b/src/Umbraco.Core/Persistence/PetaPoco.cs @@ -20,12 +20,10 @@ using System.Text; using System.Configuration; using System.Data.Common; using System.Data; -using System.Globalization; using System.Text.RegularExpressions; using System.Reflection; using System.Reflection.Emit; using System.Linq.Expressions; -using System.Threading; namespace Umbraco.Core.Persistence { @@ -1804,53 +1802,8 @@ namespace Umbraco.Core.Persistence return ObjectCache; } - //static readonly ObjectCache ObjectCache = new MemoryCache("NPoco"); - private static readonly ObjectCache ObjectCache; - - // this should probably happen somewhere else...f - private static void FixCurrentCulture() - { - // get the current culture - var currentCulture = CultureInfo.CurrentCulture; - - // at the top of any culture should be the invariant culture - find it - var invariantCulture = currentCulture; - while (invariantCulture.Equals(CultureInfo.InvariantCulture) == false) - invariantCulture = invariantCulture.Parent; - - // now that invariant culture should be the same object as CultureInfo.InvariantCulture - // yet for some weird reason, sometimes it is not - and this breaks eg MemoryCache, - // because it ends up in PerformanceCounterLib.IsCustomCategory which does: - // - // CultureInfo culture = CultureInfo.CurrentCulture; - // while (culture != CultureInfo.InvariantCulture) - // { - // library = GetPerformanceCounterLib(machine, culture); - // if (library.IsCustomCategory(category)) - // return true; - // culture = culture.Parent; - // } - // - // ie a reference comparisons = enters an endless loop and hangs everything. - - if (ReferenceEquals(invariantCulture, CultureInfo.InvariantCulture)) - return; - - // so if it is not the same object, replace the culture by the "fixed" version of - // itself - this prevents MemoryCache from dying - but it is an ugly workaround and - // does not explain why we would have different CultureInfo objects - - var fixedCulture = CultureInfo.GetCultureInfo(currentCulture.Name); - Thread.CurrentThread.CurrentCulture = Thread.CurrentThread.CurrentUICulture = fixedCulture; - } - - static ManagedCache() - { - FixCurrentCulture(); - ObjectCache = new MemoryCache("NPoco"); - } - - + static readonly ObjectCache ObjectCache = new MemoryCache("NPoco"); + } public class PocoData