Fix IPropertyValueConverter determining HasValue
This commit is contained in:
@@ -87,10 +87,34 @@ namespace Umbraco.Web.PublishedCache.NuCache
|
||||
_variations = origin._variations;
|
||||
}
|
||||
|
||||
// determines whether a property has value
|
||||
public override bool HasValue(string culture = null, string segment = null)
|
||||
{
|
||||
ContextualizeVariation(ref culture, ref segment);
|
||||
return PropertyType.IsValue(GetSourceValue(culture, segment));
|
||||
|
||||
var value = GetSourceValue(culture, segment);
|
||||
var hasValue = PropertyType.IsValue(value, PropertyValueLevel.Source);
|
||||
if (hasValue.HasValue) return hasValue.Value;
|
||||
|
||||
lock (_locko)
|
||||
{
|
||||
value = GetInterValue(culture, segment);
|
||||
hasValue = PropertyType.IsValue(value, PropertyValueLevel.Inter);
|
||||
if (hasValue.HasValue) return hasValue.Value;
|
||||
|
||||
var cacheValues = GetCacheValues(PropertyType.CacheLevel).For(culture, segment);
|
||||
|
||||
// initial reference cache level always is .Content
|
||||
const PropertyCacheLevel initialCacheLevel = PropertyCacheLevel.Element;
|
||||
|
||||
if (!cacheValues.ObjectInitialized)
|
||||
{
|
||||
cacheValues.ObjectValue = PropertyType.ConvertInterToObject(_content, initialCacheLevel, value, _isPreviewing);
|
||||
cacheValues.ObjectInitialized = true;
|
||||
}
|
||||
value = cacheValues.ObjectValue;
|
||||
return PropertyType.IsValue(value, PropertyValueLevel.Object) ?? false;
|
||||
}
|
||||
}
|
||||
|
||||
// used to cache the CacheValues of this property
|
||||
|
||||
@@ -37,7 +37,28 @@ namespace Umbraco.Web.PublishedCache
|
||||
}
|
||||
|
||||
public override bool HasValue(string culture = null, string segment = null)
|
||||
=> _sourceValue != null && (!(_sourceValue is string s) || !string.IsNullOrWhiteSpace(s));
|
||||
{
|
||||
var hasValue = PropertyType.IsValue(_sourceValue, PropertyValueLevel.Source);
|
||||
if (hasValue.HasValue) return hasValue.Value;
|
||||
|
||||
GetCacheLevels(out var cacheLevel, out var referenceCacheLevel);
|
||||
|
||||
lock (_locko)
|
||||
{
|
||||
var value = GetInterValue();
|
||||
hasValue = PropertyType.IsValue(value, PropertyValueLevel.Inter);
|
||||
if (hasValue.HasValue) return hasValue.Value;
|
||||
|
||||
var cacheValues = GetCacheValues(cacheLevel);
|
||||
if (!cacheValues.ObjectInitialized)
|
||||
{
|
||||
cacheValues.ObjectValue = PropertyType.ConvertInterToObject(Element, referenceCacheLevel, value, IsPreviewing);
|
||||
cacheValues.ObjectInitialized = true;
|
||||
}
|
||||
value = cacheValues.ObjectValue;
|
||||
return PropertyType.IsValue(value, PropertyValueLevel.Object) ?? false;
|
||||
}
|
||||
}
|
||||
|
||||
// used to cache the CacheValues of this property
|
||||
// ReSharper disable InconsistentlySynchronizedField
|
||||
|
||||
Reference in New Issue
Block a user