NamelessMC / Nameless

NamelessMC is a free, easy to use & powerful website software for your Minecraft server, which includes a large range of features.
https://namelessmc.com/
MIT License
601 stars 312 forks source link

Cannot assign null to property User::$_main_group of type Group #3435

Closed DexterSK closed 11 months ago

DexterSK commented 12 months ago

Describe the issue

When registering got following error on: https://xxxxx/validate/?c=ckj39dRWaMTD71gx2caGBWt9fvbHeMVxxfisTHI3O4

NamelessMC Version

Development version

To Reproduce

  1. Register account

Expected Behaviour

No error

Screenshots

ddd

Additional Information

[2023-09-01, 15:42:45] /data/web/virtuals/311905/virtual/www/core/classes/Core/User.php(649): Cannot assign null to property User::$_main_group of type Group

PadowYT2 commented 12 months ago

Please enable debug via removing // in index.php on line 13. Also on what version are you on?

DexterSK commented 12 months ago

ddd i'm on latest 2.1.1

DexterSK commented 12 months ago

Tried to debug it and found

public function getMainGroup(): Group { die( var_dump( $this->getGroups() ) ); //this returns null array on registration

    return $this->_main_group ??= array_reduce($this->getGroups(), static function (?Group $carry, Group $group) {
        return $carry === null || $carry->order > $group->order ? $group : $carry;
    });
}
samerton commented 12 months ago

I believe this will be fixed in the next update which will hopefully be available soon.

Edit: sorry didn't see this is using the development version, we'll have to look into it, thanks for the report

samerton commented 11 months ago

Should be fixed in https://github.com/NamelessMC/Nameless/releases/tag/v2.1.2