Problem/Motivation

Firstly, thanks for an amazing module!

Adding a user to a membership group, via the add user button (admin action, path = /content/add/group_membershp) on the group home pages produces the error in response to the button:
"Deprecated function: Use of "static" in callables is deprecated in Drupal\group\Entity\GroupRole::postLoad() (line 328 of modules/contrib/group/src/Entity/GroupRole.php)."

The full error is below:

Error message
Deprecated function: Use of "static" in callables is deprecated in Drupal\group\Entity\GroupRole::postLoad() (line 328 of modules/contrib/group/src/Entity/GroupRole.php).
Drupal\group\Entity\GroupRole::postLoad(Object, Array) (Line: 389)
Drupal\Core\Entity\EntityStorageBase->postLoad(Array) (Line: 319)
Drupal\Core\Entity\EntityStorageBase->loadMultiple(Array) (Line: 352)
Drupal\Core\Entity\Plugin\EntityReferenceSelection\DefaultSelection->getReferenceableEntities() (Line: 618)
Drupal\Core\Field\Plugin\Field\FieldType\EntityReferenceItem->getSettableOptions(Object) (Line: 138)
Drupal\Core\Field\Plugin\Field\FieldWidget\OptionsWidgetBase->getOptions(Object) (Line: 32)
Drupal\Core\Field\Plugin\Field\FieldWidget\OptionsButtonsWidget->formElement(Object, 0, Array, Array, Object) (Line: 349)
Drupal\Core\Field\WidgetBase->formSingleElement(Object, 0, Array, Array, Object) (Line: 92)
Drupal\Core\Field\WidgetBase->form(Object, Array, Object) (Line: 183)
Drupal\Core\Entity\Entity\EntityFormDisplay->buildForm(Object, Array, Object) (Line: 121)
Drupal\Core\Entity\ContentEntityForm->form(Array, Object) (Line: 50)
Drupal\group\Entity\Form\GroupRelationshipForm->form(Array, Object) (Line: 106)
Drupal\Core\Entity\EntityForm->buildForm(Array, Object)
call_user_func_array(Array, Array) (Line: 534)
Drupal\Core\Form\FormBuilder->retrieveForm('group_relationship_life_wheel_group-9376111be951852_add_form', Object) (Line: 281)
Drupal\Core\Form\FormBuilder->buildForm(Object, Object) (Line: 48)
Drupal\Core\Entity\EntityFormBuilder->getForm(Object, 'add') (Line: 269)
Drupal\group\Entity\Controller\GroupRelationshipController->addForm(Object, 'group_membership')
call_user_func_array(Array, Array) (Line: 123)
Drupal\Core\EventSubscriber\EarlyRenderingControllerWrapperSubscriber->Drupal\Core\EventSubscriber\{closure}() (Line: 580)
Drupal\Core\Render\Renderer->executeInRenderContext(Object, Object) (Line: 121)
Drupal\Core\EventSubscriber\EarlyRenderingControllerWrapperSubscriber->wrapControllerExecutionInRenderContext(Array, Array) (Line: 97)
Drupal\Core\EventSubscriber\EarlyRenderingControllerWrapperSubscriber->Drupal\Core\EventSubscriber\{closure}() (Line: 163)
Symfony\Component\HttpKernel\HttpKernel->handleRaw(Object, 1) (Line: 74)
Symfony\Component\HttpKernel\HttpKernel->handle(Object, 1, 1) (Line: 58)
Drupal\Core\StackMiddleware\Session->handle(Object, 1, 1) (Line: 48)
Drupal\Core\StackMiddleware\KernelPreHandle->handle(Object, 1, 1) (Line: 106)
Drupal\page_cache\StackMiddleware\PageCache->pass(Object, 1, 1) (Line: 85)
Drupal\page_cache\StackMiddleware\PageCache->handle(Object, 1, 1) (Line: 48)
Drupal\Core\StackMiddleware\ReverseProxyMiddleware->handle(Object, 1, 1) (Line: 51)
Drupal\Core\StackMiddleware\NegotiationMiddleware->handle(Object, 1, 1) (Line: 51)
Drupal\Core\StackMiddleware\StackedHttpKernel->handle(Object, 1, 1) (Line: 686)
Drupal\Core\DrupalKernel->handle(Object) (Line: 19)

Steps to reproduce

1. Install Drupal 10.0.5 (My install is on PHP 8.1.16, running on ddev using Pantheon's core upstream)
2 . Install Group 3.0.x-dev via composer
3 . Create a group type of x (in my instance, 'life-wheel')
4 . Create a group y of group type x, (in my case called 'energy and motivation')
5 . Attempt to add a member to the group, via the group entity home page, and the admin action.

The user then appears to be added - however I am still checking that everything has worked correctly!

Proposed resolution

The user is added without an error or a call to a depreciated static function.
This appears to be the same root cause as this issue for Drupal core?
https://www.drupal.org/project/drupal/issues/3259716

Remaining tasks

User interface changes

API changes

Data model changes

Comments

adil_siddiqui’s picture

Status: Active » Needs review
StatusFileSize
new511 bytes

Patch created

kristiaanvandeneynde’s picture

Priority: Major » Normal
Status: Needs review » Reviewed & tested by the community

Found this article: https://php.watch/versions/8.2/partially-supported-callable-deprecation

I think this has my support, but we should use a syntax that is also supported by older PHP versions. Your patch seems to do just that, so RTBC. Will commit after the full release as I have already pushed tags and made preparations.

heddn’s picture

This is a duplicate of #3328660: PHP 8.2 compatibility.

kristiaanvandeneynde’s picture

Status: Reviewed & tested by the community » Closed (duplicate)

Will add credit over there.

randy tang’s picture

Version: 3.0.x-dev » 8.x-1.5
StatusFileSize
new777 bytes

Version 1.5 of drupal10 compatible

kwiechmann’s picture

Confirming the #6 versin patch resolves the "stat" in callables issue applies to Group 8.x-1.6 with PHP 8.2. The issue which this is a "duplicate" of is actually against the Group 3.x code base.

fchometon’s picture

Also confirms that patch #6 works with version 8.x-1.6 and php8.2

fenstrat’s picture

Version: 8.x-1.5 » 8.x-1.x-dev
Status: Closed (duplicate) » Reviewed & tested by the community

Confirming #6 is RTBC for the 1.x branch of group.

kristiaanvandeneynde’s picture

Status: Reviewed & tested by the community » Closed (duplicate)

Please do not reopen closed issues. This was committed in the other issue and as explained in various issues before, 8.x-1.x does not receive any feature updates or bugfixes anymore. Please upgrade to 2.x.x

socialnicheguru’s picture

Thank you for #6. I can confirm it works for group 1.6.