Skip to content

Database Cache: Fix full database cache rebuild dropping variant and composed property values (closes #21863, #21882)#21890

Merged
AndyButland merged 2 commits intomainfrom
v17/bugfix/cache-rebuild-issues
Feb 25, 2026
Merged

Database Cache: Fix full database cache rebuild dropping variant and composed property values (closes #21863, #21882)#21890
AndyButland merged 2 commits intomainfrom
v17/bugfix/cache-rebuild-issues

Conversation

@AndyButland
Copy link
Contributor

@AndyButland AndyButland commented Feb 24, 2026

Description

Fixes a regression introduced in 17.2 (PR #21207) where the "Rebuild Database Cache" dashboard action produces empty or incomplete property values in the cmsContentNu table. Per-content-type rebuilds (triggered by saving a content type) were unaffected.

Addresses #21882, #21863.

The problem

When "Rebuild Database Cache" is clicked in Settings > Published Status, DatabaseCacheRebuilder calls Rebuild([], [], []) with empty arrays, meaning "rebuild all content types." Two methods in DatabaseCacheRepository mishandled this empty input affecting variant and composition properties:

  1. GetPropertyInfoByContentType had an early return when contentTypeIds was empty, returning an empty dictionary. Without property type metadata, BuildPropertyDataDictionary treated every property as invariant (variation = 0). The downstream filter if (effectivelyVariesByCulture || string.IsNullOrEmpty(cultureCode)) then dropped all culture-specific property values because effectivelyVariesByCulture was always false and culture codes were non-empty.

  2. GetCompositionHierarchy iterated over contentTypeIds to resolve compositions and hence failed to load properties inherited from composition types.

A secondary issue existed in DocumentCacheService and MediaCacheService: ClearMemoryCacheAsync (the "Reload Memory Cache" button) cleared the HybridCache but not the _publishedContentCache ConcurrentDictionary. This meant stale converted IPublishedContent objects continued to be served until an app restart.

The fix

  • GetPropertyInfoByContentType: When contentTypeIds is empty, fetch all content type IDs from the database and use those as the effective set, rather than returning early. This matches the pattern already used by GetContentTypeVariations.
  • GetCompositionHierarchy: When contentTypeIds is empty, iterate over all child IDs found in the composition table (directParents.Keys) instead of the empty input.
  • ClearMemoryCacheAsync: Call _publishedContentCache.Clear() before clearing the HybridCache in both DocumentCacheService and MediaCacheService.

Testing

Existing and issue specific tests for this regression should pass.

#21882 provides a good description of the problem and sample project that can be used for manual testing.

Copilot AI review requested due to automatic review settings February 24, 2026 14:46
@AndyButland AndyButland changed the title Cache: Fix full database cache rebuild dropping variant and composed property values (closes #21863, closes #21882) Database Cache: Fix full database cache rebuild dropping variant and composed property values (closes #21863, closes #21882) Feb 24, 2026
@AndyButland AndyButland changed the title Database Cache: Fix full database cache rebuild dropping variant and composed property values (closes #21863, closes #21882) Database Cache: Fix full database cache rebuild dropping variant and composed property values (closes #21863, #21882) Feb 24, 2026
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 critical bugs in the database cache rebuild functionality that caused data loss during full cache rebuilds triggered from the Umbraco dashboard. The fix ensures that variant properties, composed properties, and the secondary published content cache are all correctly handled during rebuild operations.

Changes:

  • Fixed GetPropertyInfoByContentType to fetch all content type IDs when called with empty collection (full rebuild scenario), preventing variant properties from being dropped
  • Fixed GetCompositionHierarchy to handle full rebuild scenario by resolving compositions for all child types when the input collection is empty
  • Fixed ClearMemoryCacheAsync in both DocumentCacheService and MediaCacheService to clear the secondary _publishedContentCache dictionary, preventing stale content from being served
  • Added comprehensive integration tests covering invariant content, variant culture-specific properties, and composed properties during full rebuild

Reviewed changes

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

File Description
tests/Umbraco.Tests.Integration/Umbraco.PublishedCache.HybridCache/DocumentCacheServiceTests.cs Added three integration tests to verify full rebuild correctly handles invariant content, variant properties, and composed properties; added IDatabaseCacheRebuilder service accessor for testing full rebuild path
src/Umbraco.PublishedCache.HybridCache/Services/MediaCacheService.cs Added _publishedContentCache.Clear() call at the start of ClearMemoryCacheAsync to prevent serving stale cached content
src/Umbraco.PublishedCache.HybridCache/Services/DocumentCacheService.cs Added _publishedContentCache.Clear() call at the start of ClearMemoryCacheAsync to prevent serving stale cached content
src/Umbraco.PublishedCache.HybridCache/Persistence/DatabaseCacheRepository.cs Modified GetPropertyInfoByContentType to fetch all content type IDs when input is empty; updated GetCompositionHierarchy to handle empty input by using all child IDs from composition table

Copy link
Member

@Zeegaan Zeegaan left a comment

Choose a reason for hiding this comment

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

Looks good and tests good, especially love the integration tests 🚀

@AndyButland AndyButland merged commit 09206a6 into main Feb 25, 2026
25 of 26 checks passed
@AndyButland AndyButland deleted the v17/bugfix/cache-rebuild-issues branch February 25, 2026 06:42
AndyButland added a commit that referenced this pull request Feb 25, 2026
…composed property values (closes #21863, #21882) (#21890)

* Resolve full database cache rebuild dropping variant and composed property values

* Addressed feedback from code review.
@AndyButland
Copy link
Contributor Author

Cherry-picked into release/17.2.1.

alexsee pushed a commit to alexsee/umbraco-container that referenced this pull request Mar 7, 2026
Updated [Umbraco.Cms](https://github.com/umbraco/Umbraco-CMS) from
17.2.0 to 17.2.1.

<details>
<summary>Release notes</summary>

_Sourced from [Umbraco.Cms's
releases](https://github.com/umbraco/Umbraco-CMS/releases)._

## 17.2.1

## What's Changed

### 🐛 Bug Fixes

* URL Info: Fix invariant content URLs missing under non-default
language domains (closes #​21866) by @​AndyButland in
umbraco/Umbraco-CMS#21883
* Database Cache: Fix full database cache rebuild dropping variant and
composed property values (closes #​21863, #​21882) by @​AndyButland in
umbraco/Umbraco-CMS#21890

**Full Changelog**:
umbraco/Umbraco-CMS@release-17.2.0...release-17.2.1

Commits viewable in [compare
view](umbraco/Umbraco-CMS@release-17.2.0...release-17.2.1).
</details>

Updated
[Umbraco.Cms.Persistence.Sqlite](https://github.com/umbraco/Umbraco-CMS)
from 17.2.0 to 17.2.1.

<details>
<summary>Release notes</summary>

_Sourced from [Umbraco.Cms.Persistence.Sqlite's
releases](https://github.com/umbraco/Umbraco-CMS/releases)._

## 17.2.1

## What's Changed

### 🐛 Bug Fixes

* URL Info: Fix invariant content URLs missing under non-default
language domains (closes #​21866) by @​AndyButland in
umbraco/Umbraco-CMS#21883
* Database Cache: Fix full database cache rebuild dropping variant and
composed property values (closes #​21863, #​21882) by @​AndyButland in
umbraco/Umbraco-CMS#21890

**Full Changelog**:
umbraco/Umbraco-CMS@release-17.2.0...release-17.2.1

Commits viewable in [compare
view](umbraco/Umbraco-CMS@release-17.2.0...release-17.2.1).
</details>

Dependabot will resolve any conflicts with this PR as long as you don't
alter it yourself. You can also trigger a rebase manually by commenting
`@dependabot rebase`.

[//]: # (dependabot-automerge-start)
[//]: # (dependabot-automerge-end)

---

<details>
<summary>Dependabot commands and options</summary>
<br />

You can trigger Dependabot actions by commenting on this PR:
- `@dependabot rebase` will rebase this PR
- `@dependabot recreate` will recreate this PR, overwriting any edits
that have been made to it
- `@dependabot show <dependency name> ignore conditions` will show all
of the ignore conditions of the specified dependency
- `@dependabot ignore this major version` will close this PR and stop
Dependabot creating any more for this major version (unless you reopen
the PR or upgrade to it yourself)
- `@dependabot ignore this minor version` will close this PR and stop
Dependabot creating any more for this minor version (unless you reopen
the PR or upgrade to it yourself)
- `@dependabot ignore this dependency` will close this PR and stop
Dependabot creating any more for this dependency (unless you reopen the
PR or upgrade to it yourself)


</details>

Signed-off-by: dependabot[bot] <support@github.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
alexsee pushed a commit to alexsee/umbraco-container that referenced this pull request Mar 7, 2026
Updated [Umbraco.Cms](https://github.com/umbraco/Umbraco-CMS) from
17.2.0 to 17.2.1.

<details>
<summary>Release notes</summary>

_Sourced from [Umbraco.Cms's
releases](https://github.com/umbraco/Umbraco-CMS/releases)._

## 17.2.1

## What's Changed

### 🐛 Bug Fixes

* URL Info: Fix invariant content URLs missing under non-default
language domains (closes #​21866) by @​AndyButland in
umbraco/Umbraco-CMS#21883
* Database Cache: Fix full database cache rebuild dropping variant and
composed property values (closes #​21863, #​21882) by @​AndyButland in
umbraco/Umbraco-CMS#21890

**Full Changelog**:
umbraco/Umbraco-CMS@release-17.2.0...release-17.2.1

Commits viewable in [compare
view](umbraco/Umbraco-CMS@release-17.2.0...release-17.2.1).
</details>

Updated
[Umbraco.Cms.Persistence.Sqlite](https://github.com/umbraco/Umbraco-CMS)
from 17.2.0 to 17.2.1.

<details>
<summary>Release notes</summary>

_Sourced from [Umbraco.Cms.Persistence.Sqlite's
releases](https://github.com/umbraco/Umbraco-CMS/releases)._

## 17.2.1

## What's Changed

### 🐛 Bug Fixes

* URL Info: Fix invariant content URLs missing under non-default
language domains (closes #​21866) by @​AndyButland in
umbraco/Umbraco-CMS#21883
* Database Cache: Fix full database cache rebuild dropping variant and
composed property values (closes #​21863, #​21882) by @​AndyButland in
umbraco/Umbraco-CMS#21890

**Full Changelog**:
umbraco/Umbraco-CMS@release-17.2.0...release-17.2.1

Commits viewable in [compare
view](umbraco/Umbraco-CMS@release-17.2.0...release-17.2.1).
</details>

Dependabot will resolve any conflicts with this PR as long as you don't
alter it yourself. You can also trigger a rebase manually by commenting
`@dependabot rebase`.

[//]: # (dependabot-automerge-start)
[//]: # (dependabot-automerge-end)

---

<details>
<summary>Dependabot commands and options</summary>
<br />

You can trigger Dependabot actions by commenting on this PR:
- `@dependabot rebase` will rebase this PR
- `@dependabot recreate` will recreate this PR, overwriting any edits
that have been made to it
- `@dependabot show <dependency name> ignore conditions` will show all
of the ignore conditions of the specified dependency
- `@dependabot ignore this major version` will close this PR and stop
Dependabot creating any more for this major version (unless you reopen
the PR or upgrade to it yourself)
- `@dependabot ignore this minor version` will close this PR and stop
Dependabot creating any more for this minor version (unless you reopen
the PR or upgrade to it yourself)
- `@dependabot ignore this dependency` will close this PR and stop
Dependabot creating any more for this dependency (unless you reopen the
PR or upgrade to it yourself)


</details>

Signed-off-by: dependabot[bot] <support@github.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
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.

3 participants