Repository navigation
Imported block values match what Umbraco publishes (#1097) - #1098
Conversation
An invariant block editor holding culture variant elements is re-serialized by Umbraco on publish (a per culture merge), and the pending changes flag is a string compare of the draft and published values. The draft uSync wrote differed in three ways: editorAlias was null (PropertyType was never set), properties were in alphabetical order, and values were not sorted by culture. On import we now set each value's PropertyType, sort values by culture, and serialize with Umbraco's property order. Export output is unchanged. Tests run the import through Umbraco's own BlockListPropertyEditor merge and compare the draft to the published value. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…nged Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Tested on a site (Umbraco 17.7.0)I set up a Source/Target pair on Umbraco 17.7.0 with two languages (en-US, fr-FR). Source recreates the setup from #1097:
The page is saved through
With 17.4.2 the imported draft had I also restarted Target without wiping the database, so the startup import ran again over the existing content. The page wasn't changed. That import did report 3 unrelated changes (the Block List data type and two seed content types): |
publish-nightly was limited to v17/main, so a prerelease run from a feature
branch built and packed but never reached the feed. The workflow is manual
only, so let any branch publish.
To keep branch builds distinguishable from main nightlies, non-main branches
are versioned "{version}-branch.{branch}.{date}.{run}" instead of
"{version}-prerelease.{date}.{run}". They sort below main nightlies, so a
floating prerelease range won't pick one up by accident.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Fixes #1097
Problem
For a culture-variant document with an invariant block property that holds culture-variant elements, Umbraco doesn't copy the draft on publish. It merges each culture (
MergePartialPropertyValueForCulture) and re-serializes the value with its own serializer. The pending-changes flag is then a plain string compare of the draft and published values (PropertyFactory.BuildDtos), so any textual difference flags the default culture as edited.The block value uSync wrote on import differed from Umbraco's in three ways:
editorAliaswasnull. It's computed fromBlockPropertyValue.PropertyType, which is[JsonIgnore]and was never set after deserializing.OrderedPropertiesJsonResolver. Umbraco writes them in declaration order.Fix
SyncBlockMapperBase, import path only:PropertyTypefrom the element property typeOrdinalIgnoreCase), as Umbraco doesExport output is unchanged, so existing uSync files don't churn. Block List, Block Grid and Single Block all share the base class.
Side effects
IsUpdatedValueis a plainEquals), so they were rewritten whenever their item was imported. Now they're left alone.Tests
uSync.Tests/Mappers/BlockListMapperPublishTests.csruns the import through the mapper collection, then through Umbraco's ownBlockListPropertyEditorper-culture publish merge. Umbraco's value editor isinternal, so it's created by reflection.editorAliasis filled inAll four fail without the fix. Full suite: 164/164 passing.
Also tested on an Umbraco 17.7.0 site pair with the steps from the issue. Released uSync reproduces the pending changes and this branch doesn't; results are in the comments.
🤖 Generated with Claude Code