Skip to content

Move persistence of relations from repository into notification handlers#20095

Merged
Migaroez merged 6 commits intomainfrom
v16/improvement/move-relation-persistence-to-a-notification-handler
Sep 9, 2025
Merged

Move persistence of relations from repository into notification handlers#20095
Migaroez merged 6 commits intomainfrom
v16/improvement/move-relation-persistence-to-a-notification-handler

Conversation

@AndyButland
Copy link
Copy Markdown
Contributor

@AndyButland AndyButland commented Sep 5, 2025

Description

See #20079 (review) for the background to raising this PR, which relate to optimising and making more reliable save operations to support Deploy operations.

Also #20094.

I've moved the persistence of relations from the repositories into a notification handler.

In testing I can see it working as it did before.

Referencing some discussion from when this was first implemented around whether this should be carried out in an event (at the time, as it was Umbraco 8), or in the repository itself:
https://github.com/umbraco/Umbraco-CMS/pull/6843/files#r338926734

Testing

Via a database query, find the references for a given parent item - e.g. a document, that has pickers for documents, media or members; or any other property editor that holds references to other nodes:

select * from umbracoRelation where ParentId = {id}

Experiment with adding and removing related items, saving and publishing, and verifying that the related records are as expected.

AndyButland and others added 2 commits September 5, 2025 16:30
@AndyButland AndyButland marked this pull request as ready for review September 5, 2025 14:32
Copilot AI review requested due to automatic review settings September 5, 2025 14:32
Copy link
Copy Markdown
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 refactors the persistence of relations from being handled directly in repositories to using notification handlers, improving the architecture and supporting Deploy operations optimization.

Key changes:

  • Removes PersistRelations calls from repository persistence methods
  • Creates a new ContentRelationsUpdate notification handler to manage relation persistence
  • Registers the notification handler for content saved/published events

Reviewed Changes

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

Show a summary per file
File Description
MemberRepository.cs Removes PersistRelations calls from new and updated item persistence methods
MediaRepository.cs Removes PersistRelations calls from new and updated item persistence methods
DocumentRepository.cs Removes PersistRelations calls from new and updated item persistence methods
ContentRepositoryBase.cs Marks PersistRelations method as obsolete and converts to no-op with warning log
ContentRelationsUpdate.cs New notification handler implementing relation persistence logic for all content types
UmbracoBuilder.CoreServices.cs Registers the new notification handler for content saved/published events

AndyButland and others added 3 commits September 5, 2025 16:34
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
@Migaroez Migaroez merged commit be8fee1 into main Sep 9, 2025
24 of 25 checks passed
@Migaroez Migaroez deleted the v16/improvement/move-relation-persistence-to-a-notification-handler branch September 9, 2025 14:03
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants