Open mistyn8 opened 4 months ago
resultant conversion.. Which actually now I look closely has stripped an existing mediaPicker3
for ogImage
, as well as Images:
in the grid from dtge being []
<?xml version="1.0" encoding="utf-8"?>
<Content Key="81c190e0-7b28-481e-8b27-d138d81152c6" Alias="Charity Support" Level="2">
<Info>
<Parent Key="4b5454af-0fe2-4529-9972-31be8df1cae9">bw</Parent>
<Path>/bw/CharitySupport</Path>
<Trashed>false</Trashed>
<ContentType>contentPage</ContentType>
<CreateDate>2021-10-07T16:15:41</CreateDate>
<NodeName Default="Charity Support" />
<SortOrder>30</SortOrder>
<Published Default="true" />
<Schedule />
<Template Key="da457eee-784b-4d85-bd24-c102089c2a9a">ContentPage</Template>
</Info>
<Properties>
<accentColour>
<Value><![CDATA[]]></Value>
</accentColour>
<confidences>
<Value><![CDATA[]]></Value>
</confidences>
<hideConfidences>
<Value><![CDATA[0]]></Value>
</hideConfidences>
<hideFromHtmlSitemap>
<Value><![CDATA[0]]></Value>
</hideFromHtmlSitemap>
<hideFromSearch>
<Value><![CDATA[0]]></Value>
</hideFromSearch>
<hidePromoBanner>
<Value><![CDATA[0]]></Value>
</hidePromoBanner>
<listingIcon>
<Value><![CDATA[]]></Value>
</listingIcon>
<listingImage>
<Value><![CDATA[]]></Value>
</listingImage>
<listingSnippet>
<Value><![CDATA[]]></Value>
</listingSnippet>
<listingTitle>
<Value><![CDATA[]]></Value>
</listingTitle>
<mainSectionClass>
<Value><![CDATA[]]></Value>
</mainSectionClass>
<menuText>
<Value><![CDATA[]]></Value>
</menuText>
<ogDescription>
<Value><![CDATA[]]></Value>
</ogDescription>
<ogImage>
<Value><![CDATA[[]]]></Value>
</ogImage>
<ogTitle>
<Value><![CDATA[BW Auctions, Sales and Remarketing]]></Value>
</ogTitle>
<pageBody>
<Value><![CDATA[{
"layout": {
"Umbraco.BlockGrid": [
{
"contentUdi": "umb://element/eef2bb1ad8ed4692a26955108b5c00f0",
"settingsUdi": "umb://element/eef2bb1ad8ed4692a26955108b5c00f0",
"columnSpan": 12,
"rowSpan": 1,
"areas": [
{
"key": "bcfd72d1-259f-3cda-b572-bed732f2c333",
"items": [
{
"contentUdi": "umb://element/8510a8d92f3a469bafa141a960e6d931",
"columnSpan": 8,
"rowSpan": 1,
"areas": []
}
]
},
{
"key": "eb36d1a5-c92c-3b61-8335-455f5a12deee",
"items": [
{
"contentUdi": "umb://element/3083b626627d4c77b75c1a5d6421ec58",
"columnSpan": 4,
"rowSpan": 1,
"areas": []
}
]
}
]
}
]
},
"contentData": [
{
"contentTypeKey": "016981ac-29fe-43fd-9298-f5df2ecfca6f",
"udi": "umb://element/8510a8d92f3a469bafa141a960e6d931",
"text": "<h3><strong>Lead Charity: St Michaels Hospice, Herefordshire</strong></h3>\n<p>St Michael’s has been at the forefront of the Hospice care movement since 1984. By sharing their knowledge and expertise with other healthcare professionals, they have played an important role in revolutionising palliative care.</p>\n<p>With patients living longer than ever before, their professional staff and trained volunteers are committed to improving the quality of life for the patients and their families and carers.</p>",
"padding": "1",
"backgroundColour": "",
"accentColour": ""
},
{
"contentTypeKey": "9dc20f98-5e70-4416-aeab-6916e9578d0b",
"udi": "umb://element/3083b626627d4c77b75c1a5d6421ec58",
"images": "[]",
"showInCarousel": "0",
"cTALink": [],
"imageCropSetting": "",
"setAsBackgroundImage": "0"
},
{
"contentTypeKey": "cf4c9668-e11c-3d37-8d04-9aac10868781",
"udi": "umb://element/eef2bb1ad8ed4692a26955108b5c00f0"
}
],
"settingsData": [
{
"contentTypeKey": "b986e86b-7810-322a-a051-47b7ef84b732",
"udi": "umb://element/eef2bb1ad8ed4692a26955108b5c00f0",
"fullScreen": "1"
}
]
}]]></Value>
</pageBody>
<pageClass>
<Value><![CDATA[]]></Value>
</pageClass>
<promoBanner>
<Value><![CDATA[]]></Value>
</promoBanner>
<seoDescription>
<Value><![CDATA[]]></Value>
</seoDescription>
<seoTitle>
<Value><![CDATA[BW Auctions, Sales and Remarketing]]></Value>
</seoTitle>
<seoXmlSiteMapHide>
<Value><![CDATA[0]]></Value>
</seoXmlSiteMapHide>
<umbracoInternalRedirectId>
<Value><![CDATA[]]></Value>
</umbracoInternalRedirectId>
<umbracoNaviHide>
<Value><![CDATA[0]]></Value>
</umbracoNaviHide>
<umbracoRedirect>
<Value><![CDATA[]]></Value>
</umbracoRedirect>
<umbracoUrlAlias>
<Value><![CDATA[]]></Value>
</umbracoUrlAlias>
<umbracoUrlName>
<Value><![CDATA[]]></Value>
</umbracoUrlName>
</Properties>
</Content>
And here is it exiting the content conversion.. with the corresponding a55c69bb47c64d8fa7a5e4d536f3a1b5
mediaKey?
Further digging, and it seems to loop through twice trying to update mediaPicker to mediaPicker3, though the contentAlias is still mediaPicker on the second iteration whilst the contentProperty.Value is already in the mediaPicker3 format..
adding a quick and dirty check for mediaKey
seems to work for now
public override string? GetContentValue(SyncMigrationContentProperty contentProperty, SyncMigrationContext context)
{
if (string.IsNullOrWhiteSpace(contentProperty.Value))
{
return contentProperty.Value;
}
//TODO: check it's not mediaPicker3Already... (seems to loop though twice for grid, and wipes out the ogImage)
if (contentProperty.Value.Contains("mediaKey"))
{
return contentProperty.Value;
}
//otherwsie try and convert
var x = base.GetContentValue(contentProperty, context);
return x;
}
or maybe better??
try
{
var mp3 = JsonConvert.DeserializeObject<IEnumerable<MediaWithCropsDto>>(contentProperty.Value);
return contentProperty.Value;
}
catch { }
or maybe better??
try { var mp3 = JsonConvert.DeserializeObject<IEnumerable<MediaWithCropsDto>>(contentProperty.Value); return contentProperty.Value; } catch { }
Or this, as a pattern used in other migrators....
if (contentProperty.Value.DetectIsJson())
{
return contentProperty.Value;
}
That just checks that it is a json string though... and not that it is specifically json that is the correct schema for a mediaPicker3?
So as per the title.. Migration plan that updates legacy grid to block grid and Umbraco.MediaPicker to MediaPicker3 issues I can see that the conversions are occurring when exiting the
GetContentValue()
of themediaPickerMigrator
and the old UDI list of media is correctly changed over to {Key, MediaKey} etc... but at the end of the process the new block grid has `"images" : []" I can't see anything of note in the debug logs... I can also see that normal doctype properties do get converted correctly from legacy to mediapicker3.. so something in the internals of the DTGE block grid migrator? Any pointers on where to look in the source to try and track down the issue?