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

オープン 初心者向け
#20,595 コメント 1 件 リアクション 0 件 担当者 0 名 GitHub で見る

メンテナーはふだん 1 日以内に返信

まだ誰も着手していません。

評価

難易度
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分
マージ済み PR(30日)
471

環境構築

はじめの一歩

  1. issue を最後まで読み、次にプロジェクトのコントリビューションガイドを読みます。
  2. 着手することを issue にコメントします — 二人が同じ作業をするのを防げます。
  3. リポジトリをフォークし、ブランチを切って変更します。
  4. issue 番号を参照したプルリクエストを送ります。

craftcms/cms のほかの issue

craftcms/cms の issue をすべて見る

似ている issue

PHP の issue をもっと見る

新しい issue をメールで受け取る

初心者向けの GitHub issue を短くまとめたダイジェスト。