[5.x]: Team group saved without name and handle, so project-config/apply fails
Maintainers usually reply within 1 day
Assessment
- Difficulty
- 2/5
- Estimated time
- 1-3 hours
- Newbie friendliness
- 66/100
Research direction
Start by reading UserGroups::getTeamGroup(), UserPermissions::saveGroupPermissions(), and UserGroups::handleChangedUserGroup(); the issue identifies the missing name and handle in project config as the failure. Reproduce with the supplied craft exec steps, then run php craft project-config/apply --force to check the reported failure is resolved and the Team group config includes both fields.
Written by the indexing model from the issue text.
Description
What happened?
Description
On Craft 5.12.1 (Team), UserGroups::getTeamGroup() creates the Team group in the database only, not in the project config. It's also called from User::afterSave(). If permissions are then saved with UserPermissions::saveGroupPermissions(), the project config gets users.groups.<uid> with only permissions. The next project-config/apply (for example during a deploy) then fails.
Saving the Team permissions in Settings → Users is fine, because the controller calls saveGroup() first.
Steps to reproduce
-
On a Team install, run this with
craft exec:$pc = Craft::$app->getProjectConfig(); $pc->remove('users.groups.c55ca0a9-4bd6-409b-afd8-c1884dafecd0'); // fresh state: no Team group $group = Craft::$app->getUserGroups()->getTeamGroup(); Craft::$app->getUserPermissions()->saveGroupPermissions($group->id, ['viewusers']);The
remove()simulates a Team install where the group exists only in the database. -
Look at
config/project/users/groups/<uid>.yaml: it only haspermissions. -
Run
php craft project-config/apply --force.
Expected behavior
The Team group in the project config always has its name and handle, for example because getTeamGroup() saves the group through saveGroup(), or because saveGroupPermissions() makes sure the group exists in the project config. project-config/apply succeeds.
Actual behavior
project-config/apply fails with Undefined array key "name" in UserGroups::handleChangedUserGroup() (UserGroups.php:347).
Craft CMS version
5.12.1 (Team)
PHP version
8.5.12
Operating system and version
Debian GNU/Linux 13 (trixie), DDEV
Database type and version
MySQL 8.0.46
Image driver and version
Imagick 3.8.1 (ImageMagick 7.1.1-43)
Installed plugins and versions
- Dominant language
- PHP
- Stars
- 3.6k
- Forks
- 714
- Avg merge
- 13h 20m
- Merged PRs (30d)
- 471
Getting set up
- No Dockerfile or Docker Compose file
- No pull request template
- Read the contributing guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
More from craftcms/cms
-
repo:cms
Difficulty 2/5 1-3 hours Newbie friendliness 78/100
craftcms/cms#20613 · 1 comment ·
Maintainers usually reply within 1 day
-
repo:cms
Difficulty 2/5 1-3 hours Newbie friendliness 84/100
craftcms/cms#20596 · 1 comment ·
Maintainers usually reply within 1 day
-
[5.x]: “Save and send activation email” doesn’t send the email for users with only “Moderate users”Openbug repo:cms
Difficulty 1/5 1-3 hours Newbie friendliness 84/100
craftcms/cms#20566 · 1 comment ·
Maintainers usually reply within 1 day
-
bug repo:cms
Difficulty 2/5 1-3 hours Newbie friendliness 70/100
craftcms/cms#20205 · 1 comment ·
Maintainers usually reply within 1 day
-
bug repo:cms
Difficulty 2/5 1-3 hours Newbie friendliness 64/100
craftcms/cms#20203 · 1 comment ·
Maintainers usually reply within 1 day
Similar issues
-
Difficulty 2/5 1-3 hours Newbie friendliness 84/100
Maintainers usually reply within 3 days
-
sync-en
Difficulty 2/5 1-3 hours Newbie friendliness 74/100
Maintainers usually reply within 1 day
-
[Sync EN] Formatting improvements to "Large Objects (LOBs)" docs (#6056)Possibly taken A pull request linked to this issue is open or already merged. Opensync-en
Difficulty 1/5 Under an hour Newbie friendliness 74/100
Maintainers usually reply within 1 day
-
Перевод устарел
Difficulty 2/5 1-3 hours Newbie friendliness 73/100
Maintainers usually reply within 1 day
-
项目日志弹出窗尺寸可拉伸功能Open
Difficulty 2/5 1-3 hours Newbie friendliness 65/100
Maintainers usually reply within 1 day