Skip to content

[4.x]: Migration throws error relating to UserGroupEvent when removing a user group #15357

@russback

Description

@russback

What happened?

Description

Spotted this when working on different feature branches, so an edge case perhaps.

Steps to reproduce

  1. Create a new branch with a new user group.
  2. Create a new user group and assign a user to that group (and that group only).
  3. Switch to a different branch and run project config migration.

At this point, the following error is thrown in the console:

error: Cannot assign null to property craft\events\UserGroupEvent::$userGroup of type craft\models\UserGroup
Failed to run craft up: exit status 1

Expected behavior

User group can be removed from project config without error.

Actual behavior

Migration fails where users are assigned solely to the removed group.

Craft CMS version

4.10.5

PHP version

8.2.18

Operating system and version

No response

Database type and version

No response

Image driver and version

No response

Installed plugins and versions

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions