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

Đang mở Phù hợp với người mới
#20,595 1 bình luận 0 reaction 0 người được giao Xem trên GitHub

Maintainer thường phản hồi trong vòng 1 ngày

Chưa có ai nhận issue này.

Đánh giá

Độ khó
2/5
Thời gian dự kiến
1-3 giờ
Mức phù hợp với người mới
66/100
Loại issue
Lỗi
Độ rõ ràng
Đặc tả rõ ràng
Mức độ hoạt động
Sôi nổi
Công nghệ
php
Lĩnh vực
backend, database

Hướng nghiên cứu

Bắt đầu bằng cách đọc UserGroups::getTeamGroup(), UserPermissions::saveGroupPermissions() và UserGroups::handleChangedUserGroup(); issue xác định việc thiếu name và handle trong cấu hình dự án là nguyên nhân gây lỗi. Tái hiện lỗi bằng các bước craft exec được cung cấp, sau đó chạy php craft project-config/apply --force để kiểm tra lỗi được báo cáo đã được khắc phục và cấu hình nhóm Team có cả hai trường.

Do mô hình lập chỉ mục viết ra từ nội dung của issue.

Mô tả

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
Ngôn ngữ chính
PHP
Star
3.6k
Fork
714
Merge trung bình
13 giờ 20 phút
Pull request đã merge (30 ngày)
471

Chuẩn bị môi trường

Bắt đầu từ đâu

  1. Đọc hết issue, rồi đọc hướng dẫn đóng góp của dự án.
  2. Bình luận trên issue rằng bạn sẽ nhận — tránh hai người làm cùng một việc.
  3. Fork repository và làm thay đổi trên một nhánh.
  4. Mở pull request có tham chiếu số hiệu của issue.

Issue khác của craftcms/cms

Tất cả issue của craftcms/cms

Issue tương tự

Thêm issue về PHP

Nhận issue mới trong hộp thư của bạn

Bản tóm tắt ngắn những issue GitHub phù hợp với người mới.