-
Notifications
You must be signed in to change notification settings - Fork 2.8k
Remove property value permissions when related content and/or property types are removed #19778
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Remove property value permissions when related content and/or property types are removed #19778
Conversation
…hey are looking for user group Ids, but we are deleting a content type).
…d contents of table.
…s when deleting a document type.
There was a problem hiding this 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 pull request implements cleanup functionality for property value permissions when content types or property types are removed. The changes ensure referential integrity by automatically removing orphaned permission records that would otherwise remain in the database after their associated content types or property types are deleted.
Key changes include:
- Enhanced content type deletion to remove associated property value permissions
- Added property type removal logic to clean up permissions containing property type references
- Added database syntax support for converting GUIDs to strings across SQL Server and SQLite
- Comprehensive integration tests to verify the cleanup behavior
Reviewed Changes
Copilot reviewed 8 out of 8 changed files in this pull request and generated 3 comments.
Show a summary per file
File | Description |
---|---|
ContentTypeRepositoryBase.cs | Core logic for cleaning up property value permissions during content type and property type operations |
SqlSyntaxProviderBase.cs | Added base implementation for GUID to string conversion |
ISqlSyntaxProvider.cs | Interface method for GUID to string conversion |
SqliteSyntaxProvider.cs | SQLite-specific implementation of GUID to string conversion |
ContentTypeRepositoryTest.cs | Integration tests verifying permission cleanup behavior |
Constants-DatabaseSchema.cs | Added proper constant naming for content type tree table |
ContentType2ContentTypeDto.cs | Updated to use new constant name |
appsettings.Tests.json | Added comment for database type configuration |
Comments suppressed due to low confidence (1)
tests/Umbraco.Tests.Integration/Umbraco.Infrastructure/Persistence/Repositories/ContentTypeRepositoryTest.cs:14
- The comment suggests testing with both SQLite and LocalDb, but the test only runs with SQLite. Consider adding parameterized tests to verify the behavior works correctly across both database types, especially given the cross-database SQL syntax requirements.
using Umbraco.Cms.Core.Models;
src/Umbraco.Infrastructure/Persistence/Repositories/Implement/ContentTypeRepositoryBase.cs
Show resolved
Hide resolved
src/Umbraco.Infrastructure/Persistence/Repositories/Implement/ContentTypeRepositoryBase.cs
Show resolved
Hide resolved
@@ -20,7 +20,12 @@ public static class Tables | |||
public const string ContentType = /*TableNamePrefix*/ "cms" + "ContentType"; | |||
public const string ContentChildType = /*TableNamePrefix*/ "cms" + "ContentTypeAllowedContentType"; | |||
public const string DocumentType = /*TableNamePrefix*/ "cms" + "DocumentType"; | |||
|
|||
[Obsolete("Please use ContentTypeTree instead. Scheduled for removal in Umbraco 18.")] |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This was just some clean-up. I don't know why this constant was named ElementTypeTree
but I've updated it to something that better matches the name and content of the table.
"DELETE FROM umbracoUserGroup2Permission WHERE userGroupKey IN (SELECT [umbracoUserGroup].[Key] FROM umbracoUserGroup WHERE Id = @id)", | ||
"DELETE FROM umbracoUserGroup2GranularPermission WHERE userGroupKey IN (SELECT [umbracoUserGroup].[Key] FROM umbracoUserGroup WHERE Id = @id)", |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Not that I've removed these two. We are deleting a content type here but the query is on the user group table.
Prerequisites
Description
Granular permissions based on document property values permissions have been introduced as options on user groups. They store a reference to a content type key, a property type key and the permission allowed. However currently when content types are deleted or property types removed from a document type, they aren't deleted.
This PR adds that functionality such that:
Testing
Integration tests have been added to verify the behaviour for both scenarios.
For manual testing: