fix(core): resolve SQL error when removing user or user group#16887
fix(core): resolve SQL error when removing user or user group#16887Ibochkarev wants to merge 2 commits intomodxcms:3.xfrom
Conversation
Remove composite Acls relation from modPrincipal schema because modAccess is abstract and has no table; xPDO cascade-delete generated invalid SQL (FROM AS modAccess). Add manual ACL deletion in modPrincipal::remove() before parent::remove(), and refactor modUserGroup to rely on it. Fixes modxcms#13725
Code ReviewSummary Fixes SQL errors when removing users or user groups by removing the invalid composite Suggestions
Assessment Correct fix for a real problem — xPDO cannot cascade-delete through an abstract class. Moving ACL cleanup to Verdict: Approve |
What does it do?
Remove the composite
Aclsrelation frommodPrincipalin the schema and mysql map, becausemodAccessis abstract and has no table. xPDO cascade-delete attempted to query a non-existent table, generating invalid SQL (FROM AS modAccess). Add manual ACL deletion inmodPrincipal::remove()beforeparent::remove(), iterating overprincipal_targetstables (Context, ResourceGroup, Category, MediaSource, Namespace). RefactormodUserGroup::remove()to remove its duplicate ACL deletion block and rely onmodPrincipal::remove().Why is it needed?
When deleting a user (or user group) via the Manager, xPDO tried to cascade-delete the composite
Aclsof classmodAccess.modAccessis abstract—real tables areaccess_context,access_resource_groups, etc. xPDO could not resolve a table name and produced broken SQL, causing errors in the log even though the user was removed successfully.How to test
Related issue(s)/PR(s)
Fixes #13725