Scenario
- Site uses multiple languages.
- A node type has a taxonomy reference field which can be translated via Entity Translation.
- A user has a role with limited access to some of the terms in this taxonomy field.
Symptoms
When the user submits the node form, they get the following errors:
Notice: Undefined index: array_parents in field_default_form_errors() (line 400 of /www/modules/field/field.form.inc).
Recoverable fatal error: Argument 2 passed to drupal_array_get_nested_value() must be an array, null given, called in /www/modules/field/field.form.inc on line 400 and defined in drupal_array_get_nested_value() (line 6608 of /www/includes/common.inc).
Problem
When a node form is submitted, Taxonomy Access checks to make sure the user has appropriate access to the submitted taxonomy values. It compares values between the new node and old node in _taxonomy_access_field_validate()
. That comparison can fail because the new node is actually incomplete.
The new node is actually just a "pseudo entity" created from form values in entity_form_field_validate()
. This pseudo node will have field values for only the one language being submitted, not all values for all translations, so taxonomy_access thinks something is wrong and sets an error. The fatal error is actually just a side effect of Drupal setting a form error on elements that don't exist.
Steps to reproduce
Use the test posted below.
Comment | File | Size | Author |
---|---|---|---|
#2 | 1996994-2-taxonomy-access-field-translation.patch | 1.19 KB | milesw |
#1 | 1996994-1-taxonomy-access-field-translation-TEST.patch | 8.8 KB | milesw |
Comments
Comment #1
milesw CreditAttribution: milesw commentedHere is a test to demonstrate the problem. It sets up the following:
Note: To run the test you need the Entity Translation module in place.
Comment #2
milesw CreditAttribution: milesw commentedThis patch is the workaround we're using for now. It checks for a form_id property in the pseudo entity and hides values for other languages that would cause validation errors.
Comment #2.0
milesw CreditAttribution: milesw commentedMinor edits
Comment #2.1
milesw CreditAttribution: milesw commentedSteps to reproduce.