Deprecated function: Use of "static" in callables is deprecated - triggered when adding user to group

Created on 22 March 2023, over 1 year ago
Updated 26 February 2024, 4 months ago

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 📌 Replace usages of static::class . '::methodName' to first-class callable syntax static::method(...) Needs work

Remaining tasks

User interface changes

API changes

Data model changes

🐛 Bug report
Status

Closed: duplicate

Version

1.0

Component

Code

Created by

🇬🇧United Kingdom martin@manarock.co.uk

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

Comments & Activities

Production build 0.69.0 2024