From eb82504fc84debbaec63e6f83953d731bfbadc65 Mon Sep 17 00:00:00 2001 From: Andy9999 Date: Sun, 20 Mar 2022 15:01:48 +0100 Subject: [PATCH 1/2] Update InternalSearchControllerImpl.cs Fix for issue 5049. Caching search results needs to include the current culture in the key. --- .../Search/Internals/InternalSearchControllerImpl.cs | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/DNN Platform/Library/Services/Search/Internals/InternalSearchControllerImpl.cs b/DNN Platform/Library/Services/Search/Internals/InternalSearchControllerImpl.cs index 9ea19a8da66..5f789a2e930 100644 --- a/DNN Platform/Library/Services/Search/Internals/InternalSearchControllerImpl.cs +++ b/DNN Platform/Library/Services/Search/Internals/InternalSearchControllerImpl.cs @@ -38,7 +38,7 @@ namespace DotNetNuke.Services.Search.Internals /// ----------------------------------------------------------------------------- internal class InternalSearchControllerImpl : IInternalSearchController { - private const string SearchableModuleDefsKey = "{0}-{1}"; + private const string SearchableModuleDefsKey = "{0}-{1}-{2}"; private const string SearchableModuleDefsCacheKey = "SearchableModuleDefs"; private const string LocalizedResxFile = "~/DesktopModules/Admin/SearchResults/App_LocalResources/SearchableModules.resx"; @@ -79,7 +79,7 @@ public InternalSearchControllerImpl() public IEnumerable GetSearchContentSourceList(int portalId) { var searchableModuleDefsCacheArgs = new CacheItemArgs( - string.Format(SearchableModuleDefsKey, SearchableModuleDefsCacheKey, portalId), + string.Format(SearchableModuleDefsKey, SearchableModuleDefsCacheKey, portalId, Thread.CurrentThread.CurrentCulture), 120, CacheItemPriority.Default); var list = CBO.GetCachedObject>( @@ -92,7 +92,7 @@ public IEnumerable GetSearchContentSourceList(int portalId) public string GetSearchDocumentTypeDisplayName(SearchResult searchResult) { // ModuleDefId will be zero for non-module - var key = string.Format("{0}-{1}", searchResult.SearchTypeId, searchResult.ModuleDefId); + var key = string.Format("{0}-{1}-{2}", searchResult.SearchTypeId, searchResult.ModuleDefId, Thread.CurrentThread.CurrentCulture); var keys = CBO.Instance.GetCachedObject>( new CacheItemArgs(key, 120, CacheItemPriority.Default), this.SearchDocumentTypeDisplayNameCallBack, false); @@ -340,7 +340,7 @@ private object SearchDocumentTypeDisplayNameCallBack(CacheItemArgs cacheItem) var searchContentSources = this.GetSearchContentSourceList(portal.PortalID); foreach (var searchContentSource in searchContentSources) { - var key = string.Format("{0}-{1}", searchContentSource.SearchTypeId, searchContentSource.ModuleDefinitionId); + var key = string.Format("{0}-{1}-{2}", searchContentSource.SearchTypeId, searchContentSource.ModuleDefinitionId, Thread.CurrentThread.CurrentCulture); if (!data.ContainsKey(key)) { data.Add(key, searchContentSource.LocalizedName); From a2417aafeb82b23c4c279ae731f0ff88e851b9f9 Mon Sep 17 00:00:00 2001 From: Andy9999 Date: Sun, 20 Mar 2022 16:28:52 +0100 Subject: [PATCH 2/2] Update SearchServiceControllerTests.cs Fixed unit test to use the new key including culture. --- .../InternalServices/SearchServiceControllerTests.cs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/DNN Platform/Tests/DotNetNuke.Tests.Web/InternalServices/SearchServiceControllerTests.cs b/DNN Platform/Tests/DotNetNuke.Tests.Web/InternalServices/SearchServiceControllerTests.cs index 3264a5adb08..793fda493e3 100644 --- a/DNN Platform/Tests/DotNetNuke.Tests.Web/InternalServices/SearchServiceControllerTests.cs +++ b/DNN Platform/Tests/DotNetNuke.Tests.Web/InternalServices/SearchServiceControllerTests.cs @@ -129,8 +129,8 @@ public void SetUp() this.internalSearchController = InternalSearchController.Instance; this.mockCBO = new Mock(); - var tabKey = string.Format("{0}-{1}", TabSearchTypeId, 0); - var userKey = string.Format("{0}-{1}", UserSearchTypeId, 0); + var tabKey = string.Format("{0}-{1}-{2}", TabSearchTypeId, 0, CultureEnUs); + var userKey = string.Format("{0}-{1}-{2}", UserSearchTypeId, 0, CultureEnUs); this.mockCBO.Setup(c => c.GetCachedObject>(It.IsAny(), It.IsAny(), It.IsAny())) .Returns(new Dictionary() { { tabKey, TabSearchTypeName }, { userKey, UserSearchTypeName } }); CBO.SetTestableInstance(this.mockCBO.Object);