Handle null and missing grid values in migration

This commit is contained in:
Steve Megson
2019-08-14 21:14:48 +01:00
parent 34e45abcc7
commit 806d835a90
2 changed files with 3 additions and 3 deletions

View File

@@ -50,10 +50,10 @@ namespace Umbraco.Core.Migrations.Upgrade.V_8_1_0
var obj = JsonConvert.DeserializeObject<JObject>(value);
var allControls = obj.SelectTokens("$.sections..rows..areas..controls");
foreach (var control in allControls.SelectMany(c => c))
foreach (var control in allControls.SelectMany(c => c).OfType<JObject>())
{
var controlValue = control["value"];
if (controlValue.Type == JTokenType.String)
if (controlValue?.Type == JTokenType.String)
{
control["value"] = UpdateMediaUrls(mediaLinkPattern, controlValue.Value<string>());
}

View File

@@ -43,7 +43,7 @@ namespace Umbraco.Web.PropertyEditors
// TODO: If it's not a string, then it's a json formatted value -
// we cannot really index this in a smart way since it could be 'anything'
if (controlVal.Type == JTokenType.String)
if (controlVal?.Type == JTokenType.String)
{
var str = controlVal.Value<string>();
str = XmlHelper.CouldItBeXml(str) ? str.StripHtml() : str;