
For my setup I use https://www.drupal.org/project/forms_steps module in combination with group module.
My structure looks like this:
* main group
** subgroup
*** content type 1
*** content type 1
Because the content types are a bit bigger and belong to the subgroup of the content types I wanted to use the "Forms_steps" module. A new workflow was created, but it breaks directly when I call my custom-url.
This is the error message, unfortunately I can not follow what I have to do now.
The website encountered an unexpected error. Please try again later.
TypeError: Argument 1 passed to Drupal\group\Plugin\GroupContentEnablerBase::createAccess() must implement interface Drupal\group\Entity\GroupInterface, null given, called in /var/www/html/docroot/modules/contrib/group/src/Entity/Access/GroupContentAccessControlHandler.php on line 30 in Drupal\group\Plugin\GroupContentEnablerBase->createAccess() (line 375 of modules/contrib/group/src/Plugin/GroupContentEnablerBase.php).
Drupal\group\Plugin\GroupContentEnablerBase->createAccess(NULL, Object) (Line: 30)
Drupal\group\Entity\Access\GroupContentAccessControlHandler->checkCreateAccess(Object, Array, 'group_content_type_cedab2a3275b2') (Line: 260)
Drupal\Core\Entity\EntityAccessControlHandler->createAccess('group_content_type_cedab2a3275b2', Object, Array, ) (Line: 705)
Drupal\Core\Entity\ContentEntityBase->access('create') (Line: 151)
Drupal\forms_steps\Controller\FormsStepsController::getForm('my_group', Object, '') (Line: 40)
Drupal\forms_steps\Controller\FormsStepsController->step('my_group', 'step_1_add_my_group', '')
call_user_func_array(Array, Array) (Line: 123)
Drupal\Core\EventSubscriber\EarlyRenderingControllerWrapperSubscriber->Drupal\Core\EventSubscriber\{closure}() (Line: 573)
Drupal\Core\Render\Renderer->executeInRenderContext(Object, Object) (Line: 124)
Drupal\Core\EventSubscriber\EarlyRenderingControllerWrapperSubscriber->wrapControllerExecutionInRenderContext(Array, Array) (Line: 97)
Drupal\Core\EventSubscriber\EarlyRenderingControllerWrapperSubscriber->Drupal\Core\EventSubscriber\{closure}() (Line: 151)
Symfony\Component\HttpKernel\HttpKernel->handleRaw(Object, 1) (Line: 68)
Symfony\Component\HttpKernel\HttpKernel->handle(Object, 1, 1) (Line: 57)
Drupal\Core\StackMiddleware\Session->handle(Object, 1, 1) (Line: 47)
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: 47)
Drupal\Core\StackMiddleware\ReverseProxyMiddleware->handle(Object, 1, 1) (Line: 52)
Drupal\Core\StackMiddleware\NegotiationMiddleware->handle(Object, 1, 1) (Line: 23)
Stack\StackedHttpKernel->handle(Object, 1, 1) (Line: 694)
Drupal\Core\DrupalKernel->handle(Object) (Line: 19)
---
I think this is the same problem as here: https://www.drupal.org/project/group/issues/2872645#comment-12734916
If I change the line from the comment in the EntityBase.php, the error no longer occurs. But I always get the following error message:
Site's cache must be cleared after adding new form mode:my_group on group_content
However, the cache has been emptied, also drupal update:entities unfortunately does not bring success.
Issue fork group-3104345
Show commands
Start within a Git clone of the project using the version control instructions.
Or, if you do not have SSH keys set up on git.drupalcode.org:
Comments
Comment #2
zcht CreditAttribution: zcht commentedComment #3
sam711 CreditAttribution: sam711 as a volunteer commentedIn order for this to work you need to have a group parameter on the path. Then, it'll be upcasted and passed down to the createAccess method.
Comment #4
kerasai CreditAttribution: kerasai commentedThis is not correct.
The
$context
utilized in these access checks is provided a default value in\Drupal\Core\Entity\EntityAccessControlHandler::createAccess
, which the calling code may provide additional "context" values. It doesn't take the Drupal context system (group context is powered by route parameter) into consideration whatsoever.Attached is a patch that I'd consider a work-around, which prevents the fatal error but does not allow for access of entity creation. If entity creation is needed, a more in-depth solution would be required in order to provide the "context" value.
In my case the calling code is an IEF field widget, which does not provide the additional "context" values, but I also am not creating the referenced entities.
Comment #5
longwave#4 solves a fatal error for me when trying to view the group content entity when entity_clone is enabled:
Comment #6
matthijsI did a re-roll to apply it in combination with the patch of #2881769.
Comment #7
jedgar1mx CreditAttribution: jedgar1mx as a volunteer commented#6 is working for me. Thanks
groups - 1.5.0
drupal - 9.5.1
Comment #10
alecsmrekar CreditAttribution: alecsmrekar as a volunteer commentedOpened MR 86 that's based on the 3.x branch.
Comment #11
plachLet's fix this in the development branch first and then backport the fix.
Comment #12
kristiaanvandeneyndeI consider this a core/contrib issue. We need a way to telegraph what context values are needed on create access checks, currently contrib is left guessing with this as a result. There's nothing I can fix here in Group, sadly. I can only wait for core to give me the tools to inform other modules about the context values Group needs for the create access check.
I truly am sorry about this, though. Feel free to fire up a core issue (or find an existing one) and I'll star it to try and keep my eye on it from time to time.
Comment #13
tpzurdo CreditAttribution: tpzurdo as a volunteer commentedI am not able to create any membership in groups or edit members in a clean install. Following #6 I've added the handler for $context['group']. Seems not giving problems.
Comment #14
freddy rodriguezThe entity clone module was unable to retrieve the context values. Seems like there is a patch already: https://www.drupal.org/project/entity_clone/issues/3324878
Comment #15
chizh273 CreditAttribution: chizh273 commentedHere's a version of #13 patch for Group 2.x
Comment #16
jedgar1mx CreditAttribution: jedgar1mx as a volunteer commented#15 worked for me
groups - 2.0.0-beta4
drupal - 10.1.6
Comment #17
rafael maito CreditAttribution: rafael maito at Zoocha commented#15 worked for me, but I had to do some changes on version 3.2.2
Re-rolled patch for this version and attaching here
Comment #18
davemaxg CreditAttribution: davemaxg as a volunteer commented#17 worked for me to fix issues with entity_clone even though the error was happening when trying to edit a group relationship. Thank you!
Comment #19
carolpettirossi CreditAttribution: carolpettirossi at ImageX commentedI was facing the same error after creating a group on /group/1/member/1. patch #17 solved the issue.
Comment #20
richarddavies CreditAttribution: richarddavies at City of Portland commentedPatch for Group 2.x in #15 won't apply to Group 2.3. Here's an updated patch for Group 2.x.
Comment #21
flowweb CreditAttribution: flowweb at WebstanZ commentedRe-rolled patch from #17 for version 3.3.0
Comment #22
firewaller CreditAttribution: firewaller commentedPatch #21 fixed the issues I was having. I would strongly request that this issue get reopened since the module is nearly unusable without this fix.
Comment #23
firewaller CreditAttribution: firewaller commentedComment #24
kristiaanvandeneyndeBe very careful when using the patches provided here. It bypasses Group's access promises when certain data could not be found. Use at your own risk.
Re @firewaller please don't reopen closed issues, the module is far from unusable without this patch and I encourage you to look into which module is checking group relationship create access without providing the right context.