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
| Comment | File | Size | Author |
|---|---|---|---|
| #6 | 3349565-6.patch | 777 bytes | randy tang |
| #2 | 3349565-2.patch | 511 bytes | adil_siddiqui |
| Screenshot 2023-03-22 092108.png | 155.08 KB | martin@manarock.co.uk |
Comments
Comment #2
adil_siddiqui commentedPatch created
Comment #3
kristiaanvandeneyndeFound 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.
Comment #4
heddnThis is a duplicate of #3328660: PHP 8.2 compatibility.
Comment #5
kristiaanvandeneyndeWill add credit over there.
Comment #6
randy tang commentedVersion 1.5 of drupal10 compatible
Comment #7
kwiechmann commentedConfirming 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.
Comment #8
fchometonAlso confirms that patch #6 works with version 8.x-1.6 and php8.2
Comment #9
fenstratConfirming #6 is RTBC for the 1.x branch of group.
Comment #10
kristiaanvandeneyndePlease 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
Comment #11
socialnicheguru commentedThank you for #6. I can confirm it works for group 1.6.