Today I installed taxonomy_acces on a existing site so I had to add a term field to the basic page content type which most of the site's nodes are based on.
Now, if I try to edit any of my nodes I get the following error message:
Notice: Undefined index: und in taxonomy_access_form_alter() (Zeile 520 von /home/www/web201/html/icedv3/sites/all/modules/taxonomy_access/taxonomy_access.module).
Warning: array_keys() [function.array-keys]: The first argument should be an array in taxonomy_access_form_alter() (Zeile 520 von /home/www/web201/html/icedv3/sites/all/modules/taxonomy_access/taxonomy_access.module).
Recoverable fatal error: Argument 1 passed to taxonomy_access_create_disallowed() must be an array, null given, called in /home/www/web201/html/icedv3/sites/all/modules/taxonomy_access/taxonomy_access.module on line 528 and defined in taxonomy_access_create_disallowed() (Zeile 1257 von /home/www/web201/html/icedv3/sites/all/modules/taxonomy_access/taxonomy_access.module).
| Comment | File | Size | Author |
|---|---|---|---|
| #23 | 1214472-22.patch | 26.84 KB | xjm |
| #5 | array1.PNG | 71.42 KB | sebastian.haas |
| #5 | array2.PNG | 68.49 KB | sebastian.haas |
Comments
Comment #1
xjmFew questions so I can try to reproduce:
Comment #2
xjmEdit: Here is the line in question:
'und' is the actual value of the LANGUAGE_NONE constant. So, that means that the langcode is set as
LANGUAGE_NONEfor this field, but$form[$field_name][LANGUAGE_NONE]is not actually set.$langcodeis from$langcodes[$field_name], which is set earlier around line 468:So for some reason
field_language()is returningLANGUAGE_NONEbut that is not actually the correct value for the field. Argh. Not sure how to troubleshoot this without a multilingual installation.Comment #3
xjmHere is some additional troubleshooting to try. You will need the devel module enabled. Starting at around line 517 of
taxonomy_access.module, change this:to this:
Then, visit the form that gives the error. You should see a message with a collapsed javascript element that contains the full data structure of the field item in the form. Click on it to expand it, then also expand any collapsed child elements. Take a screenshot and post it here so I can figure out what's going on inside the form array. :)
Comment #4
xjmAn aside, #1204230: Missing hook_field_widget_form_alter() would help us avoid this problem.
Comment #5
sebastian.haas commented1.) Select, the form is displayed correctly if I use the autocomplete widget#
2.) No terms are selected in any of the existing nodes
3.) Yes, I'm doing this as administrator
4.) See question 3. I've not set any taxonomy_access specific permissions for the admin role
5.) Yes. It's german.
I've added a screenshot of the array as desired.
Another thing I wanted to mention: If I'm setting a tag via the autocomplete widget which, as I mentioned before, works for me I receive the following error message after saving:
Notice: Undefined index: #value in taxonomy_autocomplete_validate() (Zeile 1505 von /home/www/web201/html/icedv3/modules/taxonomy/taxonomy.module).
But the new term is getting saved anyway.
Comment #6
sebastian.haas commentedI have another issue that may come with this one. Although I did not set any create permission at all a user who can edit a node has also an autocomplete text field for tagging which may be related with #1214660: Hide term reference field when user cannot edit it but there is not tag displayed (but the node is tagged) and because it's a required field I'm not able to save my changes without adding any value to this field.
I think the reason for the autocomplete field not to display a tag might be the error message I received when I tagged the node as described in #5
//Edit: I just recognized that I'm even able to add a term to the tag field although there is no create or list permission set. But still thinking this is all about the error message in #5.
Comment #7
xjmAha! From the screenshot, there is a
$form[$field_name]['#language']key available in your field, and it matches the key of the field items list. Maybe we can check that instead of usingfield_language().If that doesn't work, I found a pattern for looping through available languages in _field_invoke().
Comment #8
xjmFunctions where we (attempt to) handle
$langcode:taxonomy_access_field_attach_validate()taxonomy_access_form_alter()_taxonomy_access_pre_validate()_taxonomy_access_extract_entity_field_items()Really all of these should be handled in a consistent fashion, either using the elusive API functions I've yet to find, or at least using a pattern that is factored out for reuse.
Comment #9
xjmComment #10
xjmTalked about this a bit on IRC with jhogdon, and it sounds like ours is not the correct use of
field_language(). Places we currently callfield_language():taxonomy_access_form_alter()taxonomy_access_extract_entity_field_items()Edit: And I just remembered
field_get_items()also callsfield_language(), so if the latter is unreliable for our purposes, the former will be as well. It looks like we may need to go back to looping over the fields manually.Comment #11
xjmI've spent a lot of time looking into this. I found the following information in the docs for the i18n modules:
This implies that it's possible to have multiple languages per taxonomy field, and the values for the same field may even differ across languages. So, we need to handle all languages a field may have individually. Thus, using the API may not work, and we should instead loop over all possible values.
Comment #12
xjmhttp://drupalcode.org/project/taxonomy_access.git/commit/3f1065d is a partial fix for language handling on validation. The hook_form_alter() (which causes the original issue above) still needs to be fixed.
Comment #13
xjmComment #14
iv commentedThat commit has a stray
dpm('foo');left in it.... withoutdevelenabled, it white-screens.Comment #15
xjmHaha, fixed.
Comment #16
xjmRetagging according to standard.
Comment #17
drasgardian commentedsubscribing
Comment #18
mokitger commentedsubscribing
Comment #19
Adel commentedSubscribing
Comment #20
timme77 commentedsubscribing
Comment #21
xjmI talked to Gabor about this issue yesterday. He mentioned that i18n is actually not a good model to use, and there isn't currently a UI that lets someone edit a field in multiple languages simultaneously. However, that doesn't mean there won't be one in the future, so I'm hesitant to rip out the validation refactor based on that or to use that assumption in the form alter hook.
#1232120: Improve documentation of field multiple language system is about documenting the multilingual field API generally.
Comment #22
xjmNOTE: This patch requires the patch in #1204230-36: Missing hook_field_widget_form_alter().
It should resolve this issue, as well as the following issues:
Comment #23
xjmMaybe I should actually attach the patch, eh?
Comment #24
mhahndl commentedPatch #23 works for me!
Comment #25
xjmFixed in http://drupalcode.org/project/taxonomy_access.git/commit/56c4402.