[5.x]: Team group saved without name and handle, so project-config/apply fails

未关闭 适合新手
#20,595 1 条评论 0 个 reaction 已指派 0 人 在 GitHub 查看

维护者通常 1 天内回复

@brandonkelly 已经在做这个了。

开始于 2026年11月12日。

  • #20625 来自 @brandonkelly —— 未关闭

评估

难度
2/5
预计耗时
1-3 小时
新手友好度
66/100
Issue 类型
缺陷
描述清晰度
描述清楚
活跃度
活跃
技术栈
php
领域
backend, database

调研方向

先阅读 UserGroups::getTeamGroup()、UserPermissions::saveGroupPermissions() 和 UserGroups::handleChangedUserGroup();issue 指出项目配置中缺少 name 和 handle 是故障原因。按照提供的 craft exec 步骤重现故障,然后运行 php craft project-config/apply --force,检查报告的问题是否已解决,以及 Team 组配置是否包含这两个字段。

由索引模型根据 Issue 内容生成。

描述

bug repo:cms
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
  1. 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.

  2. Look at config/project/users/groups/<uid>.yaml: it only has permissions.

  3. 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
主要语言
PHP
星标
3.6k
派生
714
平均合并
13 小时 20 分钟
30 天内合并 PR
471

环境准备

  • 没有 Dockerfile 或 Docker Compose 文件
  • 没有 Pull Request 模板
  • 阅读贡献指南

从这里开始

  1. 先读完整个 Issue,再读项目的贡献指南。
  2. 在 Issue 下留言说明你要接手 —— 这能避免两个人做同样的事。
  3. Fork 仓库,在一个分支上完成修改。
  4. 提交 Pull Request,并在描述里引用这个 Issue 编号。

craftcms/cms 的其他 Issue

查看 craftcms/cms 的全部 Issue

相似的 Issue

更多 PHP Issue

把新 issue 发到你的邮箱

精选适合新手参与的 GitHub issue 摘要。