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

Command icon 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

zcht created an issue. See original summary.

sam711’s picture

In 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.

kerasai’s picture

Status: Active » Needs review
StatusFileSize
new1.06 KB

In 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.

This 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.

longwave’s picture

Component: Group (group) » Code

#4 solves a fatal error for me when trying to view the group content entity when entity_clone is enabled:

TypeError: Drupal\group\Plugin\GroupContentEnablerBase::createAccess(): Argument #1 ($group) must be of type Drupal\group\Entity\GroupInterface, null given, called in /var/www/html/web/modules/contrib/group/src/Entity/Access/GroupContentAccessControlHandler.php on line 31 in Drupal\group\Plugin\GroupContentEnablerBase->createAccess() (line 297 of /var/www/html/web/modules/contrib/group/src/Plugin/GroupContentEnablerBase.php).

Drupal\group\Plugin\GroupContentEnablerBase->createAccess(NULL, Object) (Line: 31)
Drupal\group\Entity\Access\GroupContentAccessControlHandler->checkCreateAccess(Object, Array, 'package-group_membership') (Line: 260)
Drupal\Core\Entity\EntityAccessControlHandler->createAccess('package-group_membership', Object, Array, 1) (Line: 170)
entity_clone_entity_access(Object, 'clone', Object)
matthijs’s picture

I did a re-roll to apply it in combination with the patch of #2881769.

jedgar1mx’s picture

#6 is working for me. Thanks

groups - 1.5.0
drupal - 9.5.1

alecsmrekar made their first commit to this issue’s fork.

alecsmrekar’s picture

Opened MR 86 that's based on the 3.x branch.

plach’s picture

Version: 8.x-1.x-dev » 3.0.x-dev

Let's fix this in the development branch first and then backport the fix.

kristiaanvandeneynde’s picture

Priority: Critical » Normal
Status: Needs review » Closed (works as designed)

I 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.

tpzurdo’s picture

I 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.

freddy rodriguez’s picture

chizh273’s picture

Here's a version of #13 patch for Group 2.x

jedgar1mx’s picture

#15 worked for me

groups - 2.0.0-beta4
drupal - 10.1.6

rafael maito’s picture

#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

davemaxg’s picture

#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!

carolpettirossi’s picture

I was facing the same error after creating a group on /group/1/member/1. patch #17 solved the issue.

richarddavies’s picture

Patch for Group 2.x in #15 won't apply to Group 2.3. Here's an updated patch for Group 2.x.

flowweb’s picture

Re-rolled patch from #17 for version 3.3.0

firewaller’s picture

Patch #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.

firewaller’s picture

Status: Closed (works as designed) » Reviewed & tested by the community
kristiaanvandeneynde’s picture

Status: Reviewed & tested by the community » Closed (works as designed)

Be 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.