I have a custom node type on which I have an unlimited image field. While trying to set up a different field as this multi image field's dependant I ran into an error. When I used the Condition: value, Values input mode: Regular expression... and any regex I ran into the "PHP Fatal error: Unsupported operand types in /modules/file/file.field.inc" error when trying to edit the condition.

To reproduce:
add an image field with multiple values allowed to a node.
Set this field as a dependee for any other field.
Set the condition to value and input mode to regex
add any regex with special characters (for example ^[1-9])

I reproduced this on a clean drupal 7.27 install using both the stable release (7.x-3.0-alpha1) and current dev release (7.x-3.0-alpha1+12-dev)
I ran the standard install profile
added an image field to the 'Basic Page' content type
enabled the conditional fields module
added the Body as a dependant of the new images field
set the condition to value, and the input mode to regex
added the above regex as a filter ^[1-9]
saved the field
attempted to edit the field and voila! Whitescreen!

Side note, if the image field is set to 1 value it does not whitescreen, it just throws the following error:
Undefined offset: 0 in file_field_widget_form() (line 487 of /modules/file/file.field.inc).

I figured out the cause in the conditional_fields.admin.inc file. It is pushing the 'value' into the dependency before generating a dummy field to help with the 'insert value from widget...' option. Unfortunately there was nothing stopping it from pushing the regex into the value which was blowing up the field generation. Attached is a patch that tests to make sure it isnt a regex before setting the dummy value

Support from Acquia helps fund testing for Drupal Acquia logo

Comments

wolffereast’s picture

Status: Active » Needs review

changing status

  • peterpoe committed b97c738 on 7.x-3.x authored by wolffereast
    Issue #2257249 by wolffereast, peterpoe: Fatal error when editing...
peterpoe’s picture

Title: PHP Fatal error: Unsupported operand types in /modules/file/file.field.inc » Fatal error when editing dependency with file dependee and regexp value
Status: Needs review » Fixed

Committed, thanks!

Status: Fixed » Closed (fixed)

Automatically closed - issue fixed for 2 weeks with no activity.