diff --git a/src/Umbraco.Core/Dynamics/PropertyResult.cs b/src/Umbraco.Core/Dynamics/PropertyResult.cs index a4ba1cfb1c..0a0bfbc6e0 100644 --- a/src/Umbraco.Core/Dynamics/PropertyResult.cs +++ b/src/Umbraco.Core/Dynamics/PropertyResult.cs @@ -35,16 +35,12 @@ namespace Umbraco.Core.Dynamics public object DataValue { get { return _source == null ? _value : _source.DataValue; } } public bool HasValue { get { return _source == null || _source.HasValue; } } public object ObjectValue { get { return _source == null ? _value : _source.ObjectValue; } } - // fixme - is it OK to return null here? public object XPathValue { get { return ObjectValue == null ? null : ObjectValue.ToString(); } } // implements IHtmlString.ToHtmlString public string ToHtmlString() { - // note - use DataValue here, because that's what the original - // Razor macro engine seems to do... - - var value = DataValue; + var value = ObjectValue; return value == null ? string.Empty : value.ToString(); } } diff --git a/src/Umbraco.Core/Models/IPublishedProperty.cs b/src/Umbraco.Core/Models/IPublishedProperty.cs index 9e67c60854..45ada63e17 100644 --- a/src/Umbraco.Core/Models/IPublishedProperty.cs +++ b/src/Umbraco.Core/Models/IPublishedProperty.cs @@ -1,5 +1,3 @@ -using System; - namespace Umbraco.Core.Models { /// @@ -34,6 +32,8 @@ namespace Umbraco.Core.Models /// The XmlPublishedCache raw values are strings exclusively since they come from the Xml cache. /// For other caches that get their raw value from the database, it would be either a string, /// an integer (Int32), or a date and time (DateTime). + /// If you're using that value, you're probably wrong, unless you're doing some internal + /// Umbraco stuff. /// object DataValue { get; } diff --git a/src/Umbraco.Web/PublishedCache/XmlPublishedCache/PublishedMediaCache.cs b/src/Umbraco.Web/PublishedCache/XmlPublishedCache/PublishedMediaCache.cs index 7650b7030d..1d7dd6ab36 100644 --- a/src/Umbraco.Web/PublishedCache/XmlPublishedCache/PublishedMediaCache.cs +++ b/src/Umbraco.Web/PublishedCache/XmlPublishedCache/PublishedMediaCache.cs @@ -329,7 +329,10 @@ namespace Umbraco.Web.PublishedCache.XmlPublishedCache //is cached so will be quicker to look up. if (dd.Properties.Any(x => x.PropertyTypeAlias == UmbracoContentIndexer.NodeTypeAliasFieldName)) { - // fixme - is it OK to use DataValue here? + // so in dd.Properties, there is an IPublishedProperty with property type alias "__NodeTypeAlias" and + // that special property would contain the node type alias, which we use to get "aliases & names". That + // special property is going to be a PropertyResult (with ObjectValue == DataValue) and we + // want its value in the most simple way = it is OK to use DataValue here. var aliasesAndNames = ContentType.GetAliasesAndNames(dd.Properties.First(x => x.PropertyTypeAlias.InvariantEquals(UmbracoContentIndexer.NodeTypeAliasFieldName)).DataValue.ToString()); if (aliasesAndNames != null) { diff --git a/src/Umbraco.Web/PublishedContentExtensions.cs b/src/Umbraco.Web/PublishedContentExtensions.cs index 52e8c3fec1..65038f01c6 100644 --- a/src/Umbraco.Web/PublishedContentExtensions.cs +++ b/src/Umbraco.Web/PublishedContentExtensions.cs @@ -1619,10 +1619,10 @@ namespace Umbraco.Web }; var userVals = new Dictionary(); - // fixme - is it OK to use DataValue here? foreach (var p in from IPublishedProperty p in n.Properties where p.DataValue != null select p) - { - userVals[p.PropertyTypeAlias] = p.DataValue; // use the raw, unprocessed value + { + // probably want the "object value" of the property here... + userVals[p.PropertyTypeAlias] = p.ObjectValue; } //add the row data Core.DataTableExtensions.AddRowData(tableData, standardVals, userVals); diff --git a/src/Umbraco.Web/umbraco.presentation/library.cs b/src/Umbraco.Web/umbraco.presentation/library.cs index c441371377..ce69560255 100644 --- a/src/Umbraco.Web/umbraco.presentation/library.cs +++ b/src/Umbraco.Web/umbraco.presentation/library.cs @@ -362,10 +362,16 @@ namespace umbraco return doc.CreatorName; } - // the legacy library returns the string value from the xml cache - which means a string - // that has not be converted at all -- use DataValue here. + // in 4.9.0 the method returned the raw XML from the cache, unparsed + // starting with 5c20f4f (4.10?) the method returns prop.Value.ToString() + // where prop.Value is parsed for internal links + resolve urls - but not for macros + // comments say "fixing U4-917 and U4-821" which are not related + // if we return DataValue.ToString() we're back to the original situation + // if we return ObjectValue.ToString() we'll have macros parsed and that's nice + // + // so, use ObjectValue.ToString() here. var prop = doc.GetProperty(alias); - return prop == null ? string.Empty : prop.DataValue.ToString(); + return prop == null ? string.Empty : prop.ObjectValue.ToString(); } ///