Skip to content

Conversation

DanielBolef
Copy link
Contributor

Fixes #6434

Summary

Add cascade delete to PortalPermissions table

@valadas
Copy link
Contributor

valadas commented Apr 4, 2025

I was not able to reproduce the initial issue though, I created a child portal and a role with a user and was able to delete the portal just fine using the UI. Is there more to know about how to reproduce this issue ?

@bdukes bdukes added this to the 9.13.9 milestone Apr 4, 2025
@bdukes
Copy link
Contributor

bdukes commented Apr 4, 2025

This is about portal permissions, which were added in 9.11 via #5103. There was not a UI added to manage these yet, so you need to add them via SQL. @DanielBolef do you happen to have an example SQL query to add a permission?

@DanielBolef
Copy link
Contributor Author

Yeah, this should do it:

DECLARE @TopLevelPagePermissionId INT

SELECT @TopLevelPagePermissionId = PermissionId FROM Permission
WHERE PermissionKey = 'ADDTOPLEVELPAGE'

INSERT INTO PortalPermission (PortalId, PermissionId, AllowAccess, RoleID, UserID)
VALUES (<PortalID to be deleted>, @TopLevelPagePermissionId, 1, <RoleID on Portal to be deleted>, NULL)

That works for the real case I was encountering, but the same issue exists for User based Portal Permissions.

DECLARE @TopLevelPagePermissionId INT

SELECT @TopLevelPagePermissionId = PermissionId FROM Permission
WHERE PermissionKey = 'ADDTOPLEVELPAGE'

INSERT INTO PortalPermission (PortalId, PermissionId, AllowAccess, RoleID, UserID)
VALUES (<PortalID to be deleted>, @TopLevelPagePermissionId, 1, NULL, <UserID on Portal to be deleted>)

In my testing while creating the above SQL, I found that the bug still exists when Users have Portal Permissions on the Portal to be deleted. This is due to the fact that Users are not deleted (I think, only UserPortals are deleted?) when a Portal is deleted, so no cascade path exists to clean up the Portal Permission. I tried adding a cascade delete for the PortalId as well, but I get a may cause cycles or multiple cascade paths conflict between the cascade path for Roles and Portals. Not sure how to resolve this.

Copy link
Contributor

@donker donker left a comment

Choose a reason for hiding this comment

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

LGTM

@valadas valadas merged commit c0a602c into dnnsoftware:develop Apr 8, 2025
3 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

[Bug]: Cannot delete Portal when Portal Permissions exist
4 participants