Skip to content

Commit

Permalink
Fix null reference exception in CacheValues.For when building the Com…
Browse files Browse the repository at this point in the history
…positeStringStringKey (#17024)

* Fix null ref exeption based on IPropertyValue.Culture documentation

* Clarify comment
  • Loading branch information
Migaroez committed Sep 9, 2024
1 parent 5fe18bb commit a74d963
Showing 1 changed file with 6 additions and 0 deletions.
6 changes: 6 additions & 0 deletions src/Umbraco.PublishedCache.NuCache/Property.cs
Original file line number Diff line number Diff line change
Expand Up @@ -371,6 +371,12 @@ private class CacheValues : CacheValue

public CacheValue For(string? culture, string? segment)
{
// As noted on IPropertyValue, null value means invariant
// But as we need an actual string value to build a CompositeStringStringKey
// We need to convert null to empty
culture ??= string.Empty;
segment ??= string.Empty;

if (culture == string.Empty && segment == string.Empty)
{
return this;
Expand Down

0 comments on commit a74d963

Please sign in to comment.