Save blueprints via SaveBlueprint on the bulk save path (v16 backport) - #1036
Merged
Merged
Conversation
ContentTemplateSerializer overrides SaveItemAsync to save through IContentService.SaveBlueprint, but inherits SaveAsync(IEnumerable<IContent>) from ContentSerializer, which saves through IContentService.Save. That persists the blueprint through the regular document repository, and DocumentRepository.PersistUpdatedItem rebuilds the NodeDto with its own NodeObjectTypeId, rewriting umbracoNode.nodeObjectType from DocumentBlueprint to Document. The blueprint is then invisible to GetBlueprintById, so the next import treats it as missing and inserts it again, failing with a duplicate key on IX_umbracoNode_UniqueId. SyncHandlerRoot.PerformSecondPassImportsAsync calls SaveAsync for any item whose second pass requires a save, so this is hit on first import of a blueprint whose second pass makes changes.
Owner
|
Not sure when this one will be released, v16 is technically end of life now, but we won't rule out fixes being bundled together as some point. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Backport of #1035 to
v16/dev. Fixes #1034 on this branch.ContentTemplateSerializeroverridesSaveItemAsyncto save throughIContentService.SaveBlueprint, but inheritsSaveAsync(IEnumerable<IContent>)fromContentSerializer, which saves throughIContentService.Save.SyncHandlerRoot.PerformSecondPassImportsAsyncuses that bulk overload for any item whose second pass requires a save, so blueprints get persisted viaDocumentRepository. ItsPersistUpdatedItemrebuilds theNodeDtowithDocumentRepository.NodeObjectTypeId, rewritingumbracoNode.nodeObjectTypefromDocumentBlueprinttoDocument.Once that happens
GetBlueprintByIdcan no longer find the item, so the next import treats it as missing and tries to insert it again — failing with a duplicate key onIX_umbracoNode_UniqueId.Same change as #1035, adjusted for this branch: wrapped in
uSyncTaskHelper.FromResultOfand using the single argumentSaveBlueprint(item), to match the surrounding code.Verification
This is the branch the problem was originally found on. Against Umbraco 16.5.1 / uSync 16.1.0, on a site with 9 blueprints:
Verified end to end by running a clean install twice — empty database and freshly seeded uSync folder, first boot then a second boot — and checking
umbracoNode.nodeObjectTypeplus the import logs each time.Take whichever of this and #1035 suits you, or neither if you would rather port it yourself.