Symptoms:
Attempting to create a node at /node/add/NODE_TYPE as a non-admin user causes the following error:
Drupal\Core\Database\InvalidQueryException: Query condition 'group_content.entity_id IN ()' cannot be empty. in Drupal\Core\Database\Query\Condition->condition() (line 76 of core/lib/Drupal/Core/Database/Query/Condition.php).
Drupal\Core\Database\Query\Select->condition('group_content.entity_id', Array, 'IN') (Line: 58)
Drupal\Core\Entity\Query\Sql\Condition->compile(Object) (Line: 167)
Drupal\Core\Entity\Query\Sql\Query->compile() (Line: 86)
Drupal\Core\Entity\Query\Sql\Query->execute() (Line: 508)
Drupal\Core\Entity\EntityStorageBase->loadByProperties(Array) (Line: 140)
gnode_node_access(Object, 'delete', Object)
call_user_func_array('gnode_node_access', Array) (Line: 393)
Drupal\Core\Extension\ModuleHandler->invokeAll('node_access', Array) (Line: 76)
Drupal\Core\Entity\EntityAccessControlHandler->access(Object, 'delete', Object, 1) (Line: 73)
Drupal\node\NodeAccessControlHandler->access(Object, 'delete', NULL, ) (Line: 183)
Drupal\node\Entity\Node->access('delete') (Line: 305)
Drupal\node\NodeForm->actions(Array, Object) (Line: 194)
Drupal\Core\Entity\EntityForm->actionsElement(Array, Object) (Line: 123)
Drupal\Core\Entity\EntityForm->buildForm(Array, Object)
call_user_func_array(Array, Array) (Line: 517)
Drupal\Core\Form\FormBuilder->retrieveForm('node_project_form', Object) (Line: 276)
Drupal\Core\Form\FormBuilder->buildForm(Object, Object) (Line: 53)
Drupal\Core\Entity\EntityFormBuilder->getForm(Object) (Line: 118)
Drupal\node\Controller\NodeController->add(Object)
call_user_func_array(Array, Array) (Line: 128)
Drupal\Core\EventSubscriber\EarlyRenderingControllerWrapperSubscriber->Drupal\Core\EventSubscriber\{closure}() (Line: 577)
Drupal\Core\Render\Renderer->executeInRenderContext(Object, Object) (Line: 129)
Drupal\Core\EventSubscriber\EarlyRenderingControllerWrapperSubscriber->wrapControllerExecutionInRenderContext(Array, Array) (Line: 102)
Drupal\Core\EventSubscriber\EarlyRenderingControllerWrapperSubscriber->Drupal\Core\EventSubscriber\{closure}()
call_user_func_array(Object, Array) (Line: 139)
Symfony\Component\HttpKernel\HttpKernel->handleRaw(Object, 1) (Line: 62)
Symfony\Component\HttpKernel\HttpKernel->handle(Object, 1, 1) (Line: 62)
Drupal\Core\StackMiddleware\Session->handle(Object, 1, 1) (Line: 53)
Drupal\Core\StackMiddleware\KernelPreHandle->handle(Object, 1, 1) (Line: 51)
Drupal\Core\StackMiddleware\ReverseProxyMiddleware->handle(Object, 1, 1) (Line: 55)
Drupal\Core\StackMiddleware\NegotiationMiddleware->handle(Object, 1, 1) (Line: 23)
Stack\StackedHttpKernel->handle(Object, 1, 1) (Line: 637)
Drupal\Core\DrupalKernel->handle(Object) (Line: 19)
Steps to reproduce:
1. Create a group type named "team"
2. Create a node type named "organization"
3. Install "Group node (organization)" for "team" group type (/admin/group/types/manage/team/content)
4. Create a new user
5. Grant that user the core permission "Organization: Create new content"
6. Log in as the new user and visit /node/add/organization
Comments
Comment #2
milesw commentedComment #3
milesw commentedError is being caused by gnode_node_access() querying for group content when the node does not yet have an ID.
Patch here checks if the node is new before querying for group content.
Comment #4
kristiaanvandeneyndeOh wow, great catch! Will definitely be added to the dev branch during today's sprint!
Comment #5
johnennew commentedConfirmed this happens and the patch fixes it. There is a typo on the initial creation of the $group_contents variable (says $group_content) - here is an updated patch. Also, replaced a !count with an empty as discussed with @kristiaanvandeneynde - two minor changes so changing to RTBC...
Comment #6
kristiaanvandeneyndeInterestingly, this seems like a minor bug in core in NodeForm::actions().
It doesn't check whether the entity is new or not, whereas the parent actions() call only sets the delete button if the entity exists already. Anyways, fixing this as we should account for core/contrib calling update/view/delete on new entities even if that makes no sense at all.
Will commit with a minor refactor.
Comment #8
kristiaanvandeneyndeCommitted and gave milesw author credit as us Deeson guys were mostly nitpicking anyways :)
Comment #9
milesw commentedThanks guys, and sorry for the rushed patch. :)
Comment #13
kristiaanvandeneyndeBad testbot! :)