Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Undefined index when saving group content #256

Open
jhedstrom opened this issue Jul 22, 2016 · 7 comments
Open

Undefined index when saving group content #256

jhedstrom opened this issue Jul 22, 2016 · 7 comments

Comments

@jhedstrom
Copy link

Notice: Undefined index: field_mode in Drupal\og\Plugin\EntityReferenceSelection\OgSelection->buildEntityQuery() (line 88 of /.../modules/og/src/Plugin/EntityReferenceSelection/OgSelection.php).
@amitaibu
Copy link
Owner

Can you please provide steps to reproduce, as I'm not seeing it.

@jhedstrom
Copy link
Author

Just basic usage (however, I am on 8.2.x latest)

  1. Make page nodes to be a group
  2. Make article nodes to be group content
  3. Add a page node, titled A group
  4. Add an article node, select the page node as the group
  5. When saving I see the notice

I verified on a fresh install as I initially had workbench moderation enabled when I first saw this.

Full stack trace:

Notice: Undefined index: field_mode in Drupal\og\Plugin\EntityReferenceSelection\OgSelection->buildEntityQuery() (line 88 of /Users/jonathan.hedstrom/work/contributions/modules/og/src/Plugin/EntityReferenceSelection/OgSelection.php).
Drupal\og\Plugin\EntityReferenceSelection\OgSelection->buildEntityQuery() (Line: 321)
Drupal\Core\Entity\Plugin\EntityReferenceSelection\DefaultSelection->validateReferenceableEntities(Array) (Line: 122)
Drupal\Core\Entity\Plugin\Validation\Constraint\ValidReferenceConstraintValidator->validate(Object, Object) (Line: 185)
Drupal\Core\TypedData\Validation\RecursiveContextualValidator->validateConstraints(Object, '0000000059a6290300000000726fa538', Array) (Line: 140)
Drupal\Core\TypedData\Validation\RecursiveContextualValidator->validateNode(Object) (Line: 147)
Drupal\Core\TypedData\Validation\RecursiveContextualValidator->validateNode(Object, Array, 1) (Line: 99)
Drupal\Core\TypedData\Validation\RecursiveContextualValidator->validate(Object, NULL, NULL) (Line: 90)
Drupal\Core\TypedData\Validation\RecursiveValidator->validate(Object) (Line: 135)
Drupal\Core\TypedData\TypedData->validate() (Line: 373)
Drupal\Core\Entity\ContentEntityBase->validate() (Line: 96)
Drupal\Core\Entity\ContentEntityForm->validateForm(Array, Object)
call_user_func_array(Array, Array) (Line: 83)
Drupal\Core\Form\FormValidator->executeValidateHandlers(Array, Object) (Line: 270)
Drupal\Core\Form\FormValidator->doValidateForm(Array, Object, 'node_article_form') (Line: 119)
Drupal\Core\Form\FormValidator->validateForm('node_article_form', Array, Object) (Line: 569)
Drupal\Core\Form\FormBuilder->processForm('node_article_form', Array, Object) (Line: 314)
Drupal\Core\Form\FormBuilder->buildForm('node_article_form', Object) (Line: 48)
Drupal\Core\Entity\EntityFormBuilder->getForm(Object) (Line: 113)
Drupal\node\Controller\NodeController->add(Object)
call_user_func_array(Array, Array) (Line: 123)
Drupal\Core\EventSubscriber\EarlyRenderingControllerWrapperSubscriber->Drupal\Core\EventSubscriber\{closure}() (Line: 574)
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}()
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: 57)
Drupal\Core\StackMiddleware\Session->handle(Object, 1, 1) (Line: 47)
Drupal\Core\StackMiddleware\KernelPreHandle->handle(Object, 1, 1) (Line: 99)
Drupal\page_cache\StackMiddleware\PageCache->pass(Object, 1, 1) (Line: 78)
Drupal\page_cache\StackMiddleware\PageCache->handle(Object, 1, 1) (Line: 47)
Drupal\Core\StackMiddleware\ReverseProxyMiddleware->handle(Object, 1, 1) (Line: 50)
Drupal\Core\StackMiddleware\NegotiationMiddleware->handle(Object, 1, 1) (Line: 23)
Stack\StackedHttpKernel->handle(Object, 1, 1) (Line: 649)
Drupal\Core\DrupalKernel->handle(Object) (Line: 19)

@amitaibu
Copy link
Owner

Thanks, I'll check.

@amitaibu
Copy link
Owner

Checked on a clean installation with 8.2.x. It seems to work fine for me also using a "regular" authenticated user.

But I believe there is something there - so if you can/ want to send me your DB dump (or even better try to debug it 😄 )

@jhedstrom
Copy link
Author

I'll dig in a bit to see what's going on :)

@jhedstrom
Copy link
Author

I dug into this a bit.

The field config's handler settings by default are missing field_mode, which then throws the undefined index notice.

langcode: en
status: true
dependencies:
  config:
    - field.storage.node.og_group_ref
    - node.type.article
    - node.type.page
  module:
    - og
id: node.article.og_group_ref
field_name: og_group_ref
entity_type: node
bundle: article
label: 'Groups audience'
description: 'OG group audience reference field.'
required: false
translatable: true
default_value: {  }
default_value_callback: ''
settings:
  handler: 'og:default'
  handler_settings:
    target_bundles:
      page: page
  access_override: false
field_type: og_standard_reference

@amitaibu
Copy link
Owner

Thanks for digging! The field_mode shouldn't be saved in the config, as it's just a switch (with a terrible name) that indicates if we should return the valid groups for "My groups" or "Other Groups". So I'm not sure this config here is the problem.

(btw, Variable name could probably change to something like $my_groups_results = TRUE)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants