Repository navigation
[2.x] feat(groups)!: the admin, guest and member groups can't be deleted - #5394
Conversation
GroupPolicy now force-denies `delete` for groups 1-3 (administrator,
guest, member), so DELETE /api/groups/{1,2,3} answers 403 for every actor,
administrators included. Core depends on these groups: guests are given the
guest group, every registered user the member group, and administrators
are identified by the admin group. The moderator group and custom groups
can still be deleted.
EditGroupModal hid Delete only for the admin group; it now hides it for
the guest and member groups too.
BREAKING CHANGE: deleting the administrator, guest or member group is
refused with a 403, including for administrators.
|
Note Automated review for @novacuum. Multiple AI models with Flarum-specific knowledge reviewed this pull request for me, and a further agent verified their findings; I haven't read it myself yet. I'll look at this pull request personally as soon as I can. No actionable findings in #5394 ([2.x] feat(groups)!: the admin, guest and member groups can't be deleted). The change merges cleanly into This assessment is based on reading the code; tests were not run during this review. |
The groups page's form uploads or removes a group's icon image through core's IconImageInput and IconImageState, once the group is saved, as the group modal does. A form whose only change is saved through its own request does not save the record again. The built-in groups can't be deleted (flarum#5394), so deletion follows canDelete alone; the groups descriptor fixture now has the icon image fields, read-only and without a column.
Since flarum/framework#5394, GroupPolicy refuses to delete the admin, guest and member groups, so DELETE answers 403 even for administrators.
Summary
The administrator (1), guest (2) and member (3) groups are built in, and core depends on them:
Guest);User::groups());Deleting one of them leaves the forum in an inconsistent state. Until now nothing stopped it: an administrator, or anyone granted
group.delete, could delete groups 2 and 3, and the API also accepted deleting group 1.Changes
GroupPolicy::delete()force-denies deleting groups 1–3. Because it usesforceDeny(), the denial also applies to administrators, who otherwise pass every ability.EditGroupModalhid the Delete button only for the admin group. It now hides it for the guest and member groups too.The moderator group (4) and custom groups can still be deleted, by administrators and by users with the
group.deletepermission.Breaking change
Any client, script or extension that deletes the admin, guest or member group now gets a
403. There is no supported way to delete these groups.Tests
tests/integration/api/groups/DeleteTest.php(new):group.delete, and the groups still exist afterwards;group.deletecan delete a custom group;js/tests/integration/admin/components/EditGroupModal.test.ts(new): Delete is hidden for groups 1–3 and shown for the moderator group and a custom group.Run on SQLite and on MariaDB with a table prefix, together with the unit suite, PHPStan,
yarn testandyarn check-typings.