Error in PostModel after upgrading to 7.6.0 - GetPropertyValue<string> returns "System.String[]"
See original GitHub issueSo, I just upgraded my blog to 7.6.0 and noticed that tags and categories in the PostModel are not being deserialized correctly:
It seems that public static T GetPropertyValue<T>(this IPublishedContent content, string alias)
was changed to return the .ToString()
method of the already parsed array (Umbraco no longer returns a comma separated string).
Fix for now:
@{
var categories = Model.GetPropertyValue<IEnumerable<string>>("categories");
if (categories != null)
{
var categoriesList = categories.ToList();
foreach (var category in categoriesList)
{
<a href="@Url.ArticulateCategoryUrl(Model, category)">@category</a>
if (category != categoriesList.Last())
{
<span>, </span>
}
}
}
}
Use Model.GetPropertyValue<IEnumerable<string>>("categories")
(or tags
) instead of Model.Tags
or Model.Categories
.
My Setup
I’ve installed Articulate as local package on my local machine, then referenced the required dlls as project dependency, included the App_plugins/Articulate
folder in source control and used uSync to sync to my blog. It’s not being displayed as installed package, but everything has been working fine for about a year now.
FYI:
I’ve noticed that there have also been changes to how MediaPicker
properties are returned.
GetPropertyValue<int>("profilePicture")
did no longer return the id of the media item, so I had to use
this.GetPropertyValue<IPublishedContent>("profilePicture").Id
. I’m not sure if this is used somewhere in Articulate, but it might be of interest and related to this issue.
Issue Analytics
- State:
- Created 6 years ago
- Comments:10 (4 by maintainers)
Thank you, that’s now much clearer!
This might be due to the new property value converters, you can try to disable them and see what happens (they will be disabled by default for Upgrades, but for new installations they are enabled by default)
http://issues.umbraco.org/issue/U4-7318
https://github.com/umbraco/Umbraco-CMS/blob/dev-v7.6/src/Umbraco.Web.UI/config/umbracoSettings.Release.config#L60
This is odd because my own site is running 7.6 and works fine