How do create a group programatically

Created on 7 November 2024, 15 days ago

Problem/Motivation

We have recently upgraded to version 2.3.0 and are running into a strange bug.

We have custom code with which we also create groups programmatically.
This is what we have done so far:

        $group = \Drupal\group\Entity\Group::create(['type' => 'players']);
        $group->set('label', 'test');
        $group->setOwner(\Drupal\user\Entity\User::load('1'));
        $group->save();

After the update, however, our page is broken with the said code to the effect that although the group was created, I can no longer edit it. We are running into a deadlock here.

So I have the following question:
How is a group programmatically created correctly in version 2.x? Can anyone help here?

💬 Support request
Status

Active

Version

2.3

Component

Code

Created by

🇩🇪Germany dbielke1986

Live updates comments and jobs are added and updated live.
Sign in to follow issues

Comments & Activities

  • Issue created by @dbielke1986
  • 🇩🇪Germany dbielke1986

    It still seems to work that way. I still don't know why we ran into this deadlock.
    After importing the tape backup and trying again, everything worked - with this very code.

    Sorry for the noise...

Production build 0.71.5 2024