[Bug]: PortalController.UpdatePortalSetting does not invalidate multilingual PortalSettings cache
Maintainers usually reply within 1 day
Nobody has claimed this yet.
Assessment
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Newbie friendliness
- 55/100
Research direction
Start with PortalController.UpdatePortalSettingInternal and GetPortalSettingsDictionary, then trace how DataCache keys and clears the per-culture settings dictionaries. Add a focused regression test that primes both culture caches, updates a neutral setting, and verifies both reads return the new value without a restart or full cache clear.
Written by the indexing model from the issue text.
Description
Is there an existing issue for this?
- I have searched the existing issues
What happened?
On multilingual installations, newly created portals can keep stale portal settings in memory until DNN is restarted.
A neutral portal setting written through PortalController.UpdatePortalSetting is saved correctly to the PortalSettings table, but subsequent reads through PortalController.GetPortalSettings / GetPortalSetting can still return the old cached dictionary for each culture.
This causes extensions relying on custom portal settings to believe the setting is missing and recreate state repeatedly. In our case, 2sxc stores TsDynDataZoneId as a portal setting. The DB contains the correct TsDynDataZoneId, but DNN keeps returning a settings dictionary without that key, so every visit to Manage Apps creates another 2sxc Zone. Restarting DNN immediately fixes the issue because the private dictionary cache is cleared.
Steps to reproduce?
- Install DNN with multiple languages enabled, for example de-DE and en-US.
- Create a new multilingual portal.
- Cause DNN to load portal settings for multiple cultures before a custom neutral setting exists, for example:
- PortalController.Instance.GetPortalSettings(portalId, "de-DE")
- PortalController.Instance.GetPortalSettings(portalId, "en-US")
- Write a neutral portal setting:
- PortalController.UpdatePortalSetting(portalId, "MyCustomSetting", "value")
- Read it back through PortalController:
- PortalController.GetPortalSetting(portalController, "MyCustomSetting", portalId, "", "de-DE")
- PortalController.GetPortalSetting(portalController, "MyCustomSetting", portalId, "", "en-US")
- Compare with direct DB/DataProvider read.
Current Behavior
PortalController.GetPortalSettings / GetPortalSetting can return stale per-culture dictionaries that do not include the newly saved neutral portal setting.
The setting exists in dbo.PortalSettings and is returned by DataProvider.Instance().GetPortalSettings(portalId, cultureCode), but PortalController still returns the old cached value until DNN restart/full cache clear.
Expected Behavior
After PortalController.UpdatePortalSetting(..., clearCache: true), all PortalController read APIs should return the updated portal setting for the affected portal/cultures.
Relevant log output
Anything else?
The affected code path appears to be in PortalController.GetPortalSettingsDictionary.
It caches settings using:
DataCache.PortalSettingsCacheKey = "PortalSettings{0}{1}"
and stores the result through:
CBO.GetCachedObject<Dictionary<string, string>>(..., saveInDictionary: true)
That means the settings dictionary is stored in DataCache's private DictionaryCache.
UpdatePortalSettingInternal clears:
- DataCache.ClearPortalCache(portalId, false)
- DataCache.RemoveCache(DataCache.PortalDictionaryCacheKey)
- one HttpContext.Items entry for the active culture
but it does not remove the private DictionaryCache entries for:
- PortalSettings{portalId}de-DE
- PortalSettings{portalId}en-US
- other portal cultures
DataCache.ClearCache() does clear DictionaryCache, which explains why restarting DNN fixes the issue.
Suggested DNN-side fix:
When UpdatePortalSettingInternal runs with clearCache = true, remove PortalSettings private dictionary cache entries for the affected portal. For a neutral setting, clear all portal culture variants because neutral settings are returned through every culture dictionary.
A focused regression test should:
- Prime GetPortalSettings(portalId, "de-DE") and GetPortalSettings(portalId, "en-US") before the setting exists.
- Call PortalController.UpdatePortalSetting(portalId, "TestSetting", "value").
- Assert that GetPortalSetting(..., "de-DE") and GetPortalSetting(..., "en-US") both return "value" without restart/full cache clear.
Affected Versions
10.3.1 (latest release)
What browsers are you seeing the problem on?
No response
Code of Conduct
- I agree to follow this project's Code of Conduct
- Dominant language
- C#
- Stars
- 1.1k
- Forks
- 791
- Avg merge
- 2d 2h
- Merged PRs (30d)
- 24
Getting set up
- No Dockerfile or Docker Compose file
- Has a pull request template
- Read the contributing guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
More from dnnsoftware/Dnn.Platform
-
Status: New
Difficulty 2/5 1-3 hours Newbie friendliness 70/100
dnnsoftware/Dnn.Platform#7543 · 1 comment ·
Maintainers usually reply within 1 day
-
Status: New
Difficulty 2/5 1-3 hours Newbie friendliness 75/100
dnnsoftware/Dnn.Platform#6681 ·
Maintainers usually reply within 1 day
-
Status: New
Difficulty 2/5 1-3 hours Newbie friendliness 65/100
dnnsoftware/Dnn.Platform#6051 · 4 comments ·
Maintainers usually reply within 1 day
-
Status: New
Difficulty 3/5 1-2 days Newbie friendliness 45/100
dnnsoftware/Dnn.Platform#7555 ·
Maintainers usually reply within 1 day
-
Status: New
Difficulty 4/5 3-5 days Newbie friendliness 22/100
dnnsoftware/Dnn.Platform#7554 · 5 comments ·
Maintainers usually reply within 1 day
All issues in dnnsoftware/Dnn.Platform
Similar issues
-
area-signalr
Difficulty 2/5 1-3 hours Newbie friendliness 75/100
dotnet/aspnetcore#69842 · 1 comment ·
Maintainers usually reply within 1 day
-
Difficulty 2/5 1-3 hours Newbie friendliness 64/100
Maintainers usually reply within 2 days
-
bug needs-triage
Difficulty 2/5 Under an hour Newbie friendliness 78/100
microsoft/microsoft-ui-reactor#1373 ·
Maintainers usually reply within 1 day
-
Client customer-reported KeyVault needs-team-attention question Service Attention
Difficulty 2/5 1-3 hours Newbie friendliness 62/100
Azure/azure-sdk-for-net#63861 · 3 comments · 1 reaction ·
Maintainers usually reply within 1 day
-
:watch: Not Triaged dotnet-csharp/svc fundamentals/subsvc
Difficulty 1/5 Under an hour Newbie friendliness 85/100
Maintainers usually reply within 1 day