From 389fb100bb337cfb47cb1d47c3dcb48c0c2d45a2 Mon Sep 17 00:00:00 2001 From: Shannon Date: Tue, 8 May 2018 16:01:20 +1000 Subject: [PATCH] 'fixes' an issue where you can get any property value back due to the incorrect cache key being used --- .../Collections/CompositeStringStringKey.cs | 6 ++- .../ThreadStaticVariationContextAccessor.cs | 42 +++++++++---------- .../Services/Implement/ContentService.cs | 1 - 3 files changed, 26 insertions(+), 23 deletions(-) diff --git a/src/Umbraco.Core/Collections/CompositeStringStringKey.cs b/src/Umbraco.Core/Collections/CompositeStringStringKey.cs index 11f123f2d0..e18f91707a 100644 --- a/src/Umbraco.Core/Collections/CompositeStringStringKey.cs +++ b/src/Umbraco.Core/Collections/CompositeStringStringKey.cs @@ -20,7 +20,11 @@ namespace Umbraco.Core.Collections public CompositeStringStringKey(string key1, string key2) { _key1 = key1?.ToLowerInvariant() ?? "NULL"; - _key2 = key2?.ToLowerInvariant() ?? "NULL"; + + //fixme - we are changing this to null if it is an empty string, this is because if we don't do this than this key will not match + // anything see comments http://issues.umbraco.org/issue/U4-11227#comment=67-46399 + // since we're not dealing with segments right now and I just need to get something working, this is the 'fix' + _key2 = !key2.IsNullOrWhiteSpace() ? key2.ToLowerInvariant() : "NULL"; } public bool Equals(CompositeStringStringKey other) diff --git a/src/Umbraco.Core/Models/PublishedContent/ThreadStaticVariationContextAccessor.cs b/src/Umbraco.Core/Models/PublishedContent/ThreadStaticVariationContextAccessor.cs index f77bb3514c..70e54bb4d6 100644 --- a/src/Umbraco.Core/Models/PublishedContent/ThreadStaticVariationContextAccessor.cs +++ b/src/Umbraco.Core/Models/PublishedContent/ThreadStaticVariationContextAccessor.cs @@ -1,23 +1,23 @@ -using System; +//using System; -namespace Umbraco.Core.Models.PublishedContent -{ - /// - /// Provides a ThreadStatic-based implementation of . - /// - /// - /// Something must set the current context. - /// - public class ThreadStaticVariationContextAccessor : IVariationContextAccessor - { - [ThreadStatic] - private static VariationContext _context; +//namespace Umbraco.Core.Models.PublishedContent +//{ +// /// +// /// Provides a ThreadStatic-based implementation of . +// /// +// /// +// /// Something must set the current context. +// /// +// public class ThreadStaticVariationContextAccessor : IVariationContextAccessor +// { +// [ThreadStatic] +// private static VariationContext _context; - /// - public VariationContext VariationContext - { - get => _context; - set => _context = value; - } - } -} \ No newline at end of file +// /// +// public VariationContext VariationContext +// { +// get => _context; +// set => _context = value; +// } +// } +//} diff --git a/src/Umbraco.Core/Services/Implement/ContentService.cs b/src/Umbraco.Core/Services/Implement/ContentService.cs index 6531e0081f..be9dee5d15 100644 --- a/src/Umbraco.Core/Services/Implement/ContentService.cs +++ b/src/Umbraco.Core/Services/Implement/ContentService.cs @@ -1075,7 +1075,6 @@ namespace Umbraco.Core.Services.Implement //we need to unpublish everything if this is a mandatory language var unpublishAll = _languageRepository.GetMany().Where(x => x.Mandatory).Select(x => x.IsoCode).Contains(culture, StringComparer.InvariantCultureIgnoreCase); - //fixme - this needs to be changed when 11227 is merged! content.ClearPublishedValues(culture, segment); //now we just publish with the name cleared SaveAndPublish(content, userId);