Skip to content

Conversation

@KevinJump
Copy link
Owner

Workaround for umbraco/Umbraco-CMS#21131.

When a content item's Key changes during an import - Umbraco throws an ForeignKey exception because of the bindings to the umbracoDocumentUrl table.

This PR checks on key changes, and removes entries from that table (via the repository). - so the conflict doesn't happen.

On Save Umbraco puts new entries in the table with the new Key so this "should" be ok.

Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR addresses a foreign key constraint violation that occurs when a content item's Key changes during import. The fix involves cleaning up entries in the umbracoDocumentUrl table before the key change is applied, preventing the constraint violation. Umbraco will repopulate the table with the new Key on save.

Key Changes:

  • Introduced ISyncDocumentUrlCleaner interface and SyncDocumentUrlCleaner implementation to handle DocumentUrl table cleanup
  • Added OnKeyChange virtual method in ContentSerializerBase to allow subclasses to respond to key changes
  • Integrated URL cleaning into ContentSerializer when key changes are detected

Reviewed changes

Copilot reviewed 6 out of 6 changed files in this pull request and generated 4 comments.

Show a summary per file
File Description
uSync.Core/Documents/ISyncDocumentUrlCleaner.cs New interface for document URL cleanup functionality
uSync.Core/Documents/SyncDocumentUrlCleaner.cs Implementation that deletes DocumentUrl entries by document key using repository
uSync.Core/uSyncCoreBuilderExtensions.cs Registers the URL cleaner as a singleton service
uSync.Core/Serialization/Serializers/ContentSerializerBase.cs Adds virtual OnKeyChange method called when a content key changes
uSync.Core/Serialization/Serializers/ContentSerializer.cs Overrides OnKeyChange to invoke URL cleaner and adds it as a dependency
uSync.Core/Serialization/Serializers/ContentTemplateSerializer.cs Updates constructor to accept and pass the URL cleaner to base class

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

@KevinJump KevinJump added the Breaking Change A Change that might impact 3rd party code, or change the format of export files label Dec 15, 2025
@KevinJump
Copy link
Owner Author

KevinJump commented Dec 15, 2025

Warning

(Breaking - changes the Constructor for the ContentSerializer class)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Breaking Change A Change that might impact 3rd party code, or change the format of export files

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants