Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Cache a dictionary of dictionaries #15908

Merged

Conversation

matthewcare
Copy link
Contributor

Prerequisites

  • I have added steps to test this contribution in the description below

If there's an existing issue for this PR then this fixes
Fixes #15765

Description

The current implementation only allows for one culture dictionary to be cached at a time. This would result in the cached culture dictionary being whatever the last culture you requested was, which would have confusing results. This new implementation allows for caching all cultures.

Testing

  • Create a site with two or more cultures
  • Add some dictionary items
  • Add the following to your view
@Umbraco.GetDictionaryValue("Key")
@Umbraco.GetDictionaryValue("Key", CultureInfo.GetCultureInfo("your-other-culture"))
@Umbraco.GetDictionaryValue("Key")
  • Observe that the values are for the correct culture

Copy link

github-actions bot commented Mar 19, 2024

Hi there @matthewcare, thank you for this contribution! 👍

While we wait for one of the Core Collaborators team to have a look at your work, we wanted to let you know about that we have a checklist for some of the things we will consider during review:

  • It's clear what problem this is solving, there's a connected issue or a description of what the changes do and how to test them
  • The automated tests all pass (see "Checks" tab on this PR)
  • The level of security for this contribution is the same or improved
  • The level of performance for this contribution is the same or improved
  • Avoids creating breaking changes; note that behavioral changes might also be perceived as breaking
  • If this is a new feature, Umbraco HQ provided guidance on the implementation beforehand
  • 💡 The contribution looks original and the contributor is presumably allowed to share it

Don't worry if you got something wrong. We like to think of a pull request as the start of a conversation, we're happy to provide guidance on improving your contribution.

If you realize that you might want to make some changes then you can do that by adding new commits to the branch you created for this work and pushing new commits. They should then automatically show up as updates to this pull request.

Thanks, from your friendly Umbraco GitHub bot 🤖 🙂

@emmagarland
Copy link
Contributor

Hi @matthewcare,

Just spotted this one while merging #14787! 👍

Thanks for your PR to fix #15765, where specifying a culture in GetDictionaryValue overrides the culture dictionary for the rest of the request.

One of the Core Collaborators team will review this as soon as possible!

Best wishes

Emma

@matthewcare matthewcare force-pushed the bugfix/15765-culture-dictionary branch from 7140ec2 to 7aa06f7 Compare June 29, 2024 15:43
@matthewcare matthewcare force-pushed the bugfix/15765-culture-dictionary branch from d4d252e to 3ce2e97 Compare June 29, 2024 15:55
Re-commit change after merge
@matthewcare matthewcare reopened this Jun 29, 2024
Update usings after merge
Remove the obsolete method
@matthewcare
Copy link
Contributor Author

I made an absolute hash of updating the branch with the most recent stuff in contrib, but it should be good to go again. Just in case anyone is wondering what went on in the history there.

@emmagarland
Copy link
Contributor

Thanks @matthewcare and sorry for the delay. I'll get to testing this asap.

@emmagarland emmagarland self-assigned this Aug 16, 2024
@emmagarland emmagarland merged commit 3b6fbf1 into umbraco:contrib Aug 17, 2024
3 of 5 checks passed
@emmagarland
Copy link
Contributor

Hi @matthewcare, thanks so much for your pull request to fix the issue of the wrong value showing on a cached culture dictionary, fixing #15765.

I've tested the old behaviour and your fix resolves it.

It has now been successfully merged! 🙌

Best wishes

Emma

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Specifying a culture in GetDictionaryValue overrides the culture dictionary for the rest of the request
2 participants