Skip to content

Typed property Nucleos\UserBundle\Model\User::$groups must not be accessed before initialization #792

@gaetan-petit

Description

@gaetan-petit

Environment

Packages

nucleos/profile-bundle                   2.8.0
nucleos/user-bundle                      3.7.0 
symfony/framework-bundle                 7.3.6

PHP version

PHP 8.4.8

Subject

When logging I get an error on accessing $groups property while we aren't using the groups feature (no group_class is configure in the config yaml).

The user finder seems to fetch the user from the db without instantiating the User object by it's constructor so the property is never initialized before access.

Adding this in our User class fix the login

public function getGroups(): Collection
{
    return new ArrayCollection();
}

It was previously working with v3.6.1

This change seems to be culprit: 3.6.1...3.7.0#diff-2886a9a9577b1d57d2364a968402b5d7416d8091cbadab8f43c15b6400b671f4L246

Steps to reproduce

Logout and login

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions