Skip to content

Conversation

@AndyButland
Copy link
Contributor

Prerequisites

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

Addresses #20336

Description

In an earlier PR, we added an update to the dictionary repository such that it cached null values, and prevented multiple database hits for dictionary keys that did not exist: #15576

We then resolved this issue raised that identified some issues resulting when using localised text in the backoffice (supported in Umbraco 13): #19350

Unfortunately it seems this caused a regression on the original feature.

In this PR I've resolved the regression and tested that the backoffice translations work as expected.

I've also added integration tests to verify the cache behaviour.

Testing

See replication steps described in #20336

With the code in this PR in place, verify that you no longer see the database requests for missing dictionary items.

Release

Once approved and merged for 13.12, this will need cherry-picking up for 16.4.

Copilot AI review requested due to automatic review settings October 1, 2025 15:42
@AndyButland AndyButland changed the title V13/bugfix/fix handling of null representation in cache Caching: Fixes regression of the caching of null representations for missing dictionary items Oct 1, 2025
Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull Request Overview

This PR fixes a regression in null value caching for the dictionary repository. The issue involved the handling of a special null representation string in the cache that was incorrectly being treated as null in all contexts, breaking backoffice translations when dictionary keys didn't exist.

  • Refactored cache item retrieval logic to distinguish between actual null and the special null representation string
  • Added comprehensive integration tests to verify caching behavior for both existing and non-existing dictionary items
  • Separated null checking from null representation checking in cache extensions

Reviewed Changes

Copilot reviewed 2 out of 2 changed files in this pull request and generated 3 comments.

File Description
src/Umbraco.Core/Cache/AppCacheExtensions.cs Fixed cache retrieval logic to properly handle null representation string vs actual null values
tests/Umbraco.Tests.Integration/Umbraco.Infrastructure/Persistence/Repositories/DictionaryRepositoryTest.cs Added comprehensive integration tests for dictionary repository caching behavior

Copy link
Contributor

@kjac kjac left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@AndyButland I have added a bit more to the tests, to verify that cached null values are also flushed as expected.

If you think it makes sense, feel free to merge 👍

@AndyButland
Copy link
Contributor Author

AndyButland commented Oct 2, 2025

It does - thanks. Will do (and I'll cherry-pick for the 13.11 release and 16).

@AndyButland AndyButland enabled auto-merge (squash) October 2, 2025 07:23
@AndyButland AndyButland merged commit 7d87ce3 into v13/dev Oct 2, 2025
18 of 19 checks passed
@AndyButland AndyButland deleted the v13/bugfix/fix-handling-of-null-representation-in-cache branch October 2, 2025 07:46
AndyButland added a commit that referenced this pull request Oct 2, 2025
…missing dictionary items (#20344)

* Fixed regression with handling of null representation in cache.

* Added integration test to verify behaviour.

* Use helper methods.

* Amend tests so they verify that cached null values are also removed

---------

Co-authored-by: kjac <[email protected]>
@AndyButland
Copy link
Contributor Author

Port to 16 is in #20349 - I'll merge when the build checks are happy, as it's effectively a cherry-pick.

@AndyButland AndyButland changed the title Caching: Fixes regression of the caching of null representations for missing dictionary items Caching: Fixes regression of the caching of null representations for missing dictionary items (closes #20336 for 13) Oct 2, 2025
@umbracocommunity
Copy link

This pull request has been mentioned on Umbraco community forum. There might be relevant details there:

https://forum.umbraco.com/t/dictionary-cache-regression/6041/6

@umbracocommunity
Copy link

This pull request has been mentioned on Umbraco community forum. There might be relevant details there:

https://forum.umbraco.com/t/website-significantly-slower-since-upgrading-from-v13-to-v16/6049/9

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

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants