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.

Support from Acquia helps fund testing for Drupal Acquia logo

Comments

milesw’s picture

Here is a test to demonstrate the problem. It sets up the following:

  • English and Spanish languages installed.
  • A user role called "Translator".
  • A taxonomy vocabulary called "workflow", with terms "Draft" and "Needs Translation".
  • The Translator role can access the "Needs Translation" term but has more limited access to the "Draft" term.
  • The Page content type has a taxonomy field for "workflow" meant to represent workflow status of translations. This field is translatable via Entity Translation.

Note: To run the test you need the Entity Translation module in place.

milesw’s picture

Status: Active » Needs review
FileSize
1.19 KB

This 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.

milesw’s picture

Issue summary: View changes

Minor edits

milesw’s picture

Issue summary: View changes

Steps to reproduce.