Support for Drupal 7 is ending on 5 January 2025—it’s time to migrate to Drupal 10! Learn about the many benefits of Drupal 10 and find migration tools in our resource center.
The Following error comes whenever i am trying to post a new question in the group
Notice: Undefined index: und in commons_q_a_views_pre_render() (line 93 of /var/www/profiles/commons/modules/contrib/commons_q_a/commons_q_a.module).
Warning: Invalid argument supplied for foreach() in commons_q_a_views_pre_render() (line 93 of /var/www/profiles/commons/modules/contrib/commons_q_a/commons_q_a.module).
I have also attached a screen shot of the error page please help me with some solution as soon as possible...
Comment | File | Size | Author |
---|---|---|---|
#13 | 1953242-qa-answersref-11.patch | 4.01 KB | japerry |
#9 | 1953242-qa-answersref-9.patch | 4.03 KB | japerry |
#5 | 1953242-qa-answersref-5.patch | 3.58 KB | japerry |
#2 | question.jpg | 215.24 KB | Rafiq Jewale |
Comments
Comment #1
ezra-g CreditAttribution: ezra-g commentedCan you share the error you're receiving? It's difficult to help you without knowing what the problem is.
Comment #2
Rafiq Jewale CreditAttribution: Rafiq Jewale commentedComment #3
japerryThis can be reproduced by going to node/add/question without an og_node_ref at the end. By taking off the argument for the group, and not adding a group in the reference, it will cause this problem.
We should add a sanity check just in case, but also make the group field required for questions. This error only occurs if the group reference field is empty.
Comment #4
japerryComment #5
japerryhere is a re-write of that snippet of code.. what it changes:
1) requires that user have access to post answers in general for the answers page to show up
2) not only associates an answer with a question, but to the group the question belongs to as well. It also checks user access to only post the answer to groups which the user has access to.
3) Does a check to make sure if the group field is empty to not throw the error, which is the basis of this bug.
4) still allows a user to post an answer, even if they are not assigned to a group. As long as the user has global permission to post answers.
Comment #6
ezra-g CreditAttribution: ezra-g commentedI think this is the correct status :).
Comment #7
japerrylol what!? heh thats funny, it was late on friday ;-)
Comment #8
ezra-g CreditAttribution: ezra-g commentedI believe this needs work:
Per a comment in Commons_Groups module, the code flow for node access with OG is:
node_access()>og_node_access()=>og_user_access_entity=>og_user_access=>og_user_access_alter()=>commons_groups_og_user_access_alter().
Therefore, starting with a call to node_access() without specifying a group might deny a user the ability to create questions when she lacks permission to do so sitewide, but has permission to do so within specific groups.
So, I think we can use a single call such as
once, and show the form if the user has access to post into any of the target groups.
I believe that even with entityreference prepopulate, OG's form validation handlers will still prevent the user from posting into groups where she lacks access.
Comment #9
japerryThis should do a better check of node access permissions, and tested to work with anonymous and og_user_access for certain groups.
Comment #10
ezra-g CreditAttribution: ezra-g commentedComment #11
ezra-g CreditAttribution: ezra-g commentedLooks better!
2 questions about the below code:
IMO it would be significantly easier to follow this code if we did an if/else, instead of the if, then if (!$answer_access) followed by if($answer_access).
A code comment reads:
I think maybe this used to refer to the global $user that's at the top of the function and probably intends to read something like, "If the user doesn't have permission to create an answer, don't display the answer creation form."
Also, I received the error, "fatal: git diff header lacks filename information when removing 1 leading pathname components (line 5)" when trying to apply the above patches via git apply. patch -p1 work, but only after specifying the target filename.
Comment #12
ezra-g CreditAttribution: ezra-g commentedComment #13
japerryComment #14
japerryFixed from comments above, and patch is now using p1.. althiough that doesn't really matter once its committed ;-)
Commit here:
http://drupalcode.org/project/commons_q_a.git/commit/e03551b
Comment #16
Honestly Illustrated CreditAttribution: Honestly Illustrated commentedOn 7.x-3.2, I'm getting the same error in a different line of the same module:
Notice: Undefined index: und in commons_q_a_field_attach_submit() (line 192 of /var/www/profiles/commons/modules/contrib/commons_q_a/commons_q_a.module).
This happens any time I post an Answer reply to a Question: when done on the question node page, and through /node/add.
I was also (on the same pages and action) getting the Warning and Notice errors from #1887246: Adding content with no group generates array errors which its #8 patch solved. That patch won't pass diff --git with 7.x-3.2 as-is, but the minor change it makes can be made and does fix this instance of that bug.
Comment #17
Devin Carlson CreditAttribution: Devin Carlson commentedPlease file new issues for any problems you come across instead of hijacking and reopening existing issues.
Your issue with error notices being generated while posting questions is answers is covered by #2008930: OG reference occurs to be a bug gap if isn't set.
Comment #18
Honestly Illustrated CreditAttribution: Honestly Illustrated commentedPardon me sir, but I am not hijacking.
Do you not want people to research our problems before we bother you?
It's the same error merely on a different line. Thank you for your help, but please do not insult.
Edit: Also, I was taking cue from #1887246: Adding content with no group generates array errors where ezra-g asked for that issue to be reopened if seen again.
- $entity->og_group_ref[LANGUAGE_NONE] = $question->og_group_ref[LANGUAGE_NONE];
+ $entity->og_group_ref = $question->og_group_ref;
On .../commons_q_a.module does solve my occurrence of the error in 7.x-3.2
Comment #18.0
Honestly Illustrated CreditAttribution: Honestly Illustrated commentedAdded the error page screen shot