Update references/relations after completing scope using notifications #20094
ronaldbarendse
started this conversation in
Features and ideas
Replies: 0 comments
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
-
As mentioned in #20079 (review), the CMS currently updates all references in the document, media and member repositories by calling
ContentRepositoryBase.PersistRelations()
when inserting and updating them:DocumentRepository.PersistNewItem()
:Umbraco-CMS/src/Umbraco.Infrastructure/Persistence/Repositories/Implement/DocumentRepository.cs
Line 1077 in 472be3d
DocumentRepository.PersistUpdatedItem()
:Umbraco-CMS/src/Umbraco.Infrastructure/Persistence/Repositories/Implement/DocumentRepository.cs
Line 1328 in 472be3d
MediaRepository.PersistNewItem()
:Umbraco-CMS/src/Umbraco.Infrastructure/Persistence/Repositories/Implement/MediaRepository.cs
Line 419 in 472be3d
MediaRepository.PersistUpdatedItem()
:Umbraco-CMS/src/Umbraco.Infrastructure/Persistence/Repositories/Implement/MediaRepository.cs
Line 481 in 472be3d
MemberRepository.PersistNewItem()
:Umbraco-CMS/src/Umbraco.Infrastructure/Persistence/Repositories/Implement/MemberRepository.cs
Line 791 in 472be3d
MemberRepository.PersistUpdatedItem()
:Umbraco-CMS/src/Umbraco.Infrastructure/Persistence/Repositories/Implement/MemberRepository.cs
Line 941 in 472be3d
This results in parsing all property data on every save using
DataValueReferenceFactoryCollection.GetAllReferences()
(for both edited and published values), even if no property data is changed. This results in an unnecessary performance penalty, especially if multiple saves/publishes are done within a single Umbraco scope (like Deploy does).A bigger issue is timing: if the property data contains a reference to e.g. media, but that media isn't available yet, the CMS will not create the reference/relation. This is quite common when transferring content using Deploy: although related media items that don't exist yet will automatically be included in the transfer, there's no strict requirement for the media to be deployed first (compared to parent items that do need to exist first). Although Deploy could be updated to ensure the related media item is saved first, this can cause a cyclic dependency (when creating the
TopoGraph
).One possible solution would be to update the references/relations after completing the scope using notifications. The notification handler would need to inherit from
IDistributedNotificationHandler
to ensure it's handled after e.g. Deploy operations.Beta Was this translation helpful? Give feedback.
All reactions