Content types: Allow adding composition with clashing property alias when property is being removed (closes #21298) #21321
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.
Description
When updating a content type to add a composition and remove a property at the same time, if the composition has a property with the same alias as the one being removed, this is rejected with an
InvalidCompositionException- as raised in #21298.Having checked Umbraco 13, this wasn't the case there. You could carry out this operation. Data loss will occur - as the property is not the same given it has a new ID and isn't stored by alias. This is the case in 13 and in 17.
This PR allows the operation to succeed by passing the removed property aliases to
AddContentType, which excludes them from the conflict checkChange Summary
IContentTypeComposition.AddContentType(IContentTypeComposition contentType, string[] removedPropertyTypeAliases).ContentTypeCompositionBase.AddContentTypeto accept removed property aliases and exclude them from conflict detection.ContentTypeEditingServiceBase.UpdateCompositionsto calculate removed property aliases and pass them when adding compositions.Testing
Integration tests
Cannot_Add_Composition_With_Conflicting_Property_Type_AliasandCan_Add_Composition_With_Conflicting_Property_Type_Alias_When_Alias_Is_Being_Removedtest verify the behaviour.Manual testing steps: