When using this module in conjunction with getlocations I am receiving this error on a node add form that contains getlocations fields.

Warning: preg_match_all() expects parameter 2 to be string, array given in preg_match_all() (line 124 of /var/www/portal2/includes/token.inc).

The fields in getlocations do not have tokens set as their default values.

I'm not sure which module is at fault, but I tracked it down to field_default_token.module:81 where it calls token_replace().
It seems that getlocations field is using an array in one of its field values (it's $column_name is settings).

I fixed this issue by checking if $column_value is an array and not calling token_replace() since token_replace() expects parameter 1 to be a string according to the API https://api.drupal.org/api/drupal/includes%21token.inc/function/token_re...
It may be better to detect if the column_value is an array and iterate over that and scan the values for tokens. That would probably require a recursive function to walk through the array.

After reading a few bug reports for the token module and other modules (see related issues), I think this value should be checked if it's an array before passing it to token_replace().

Support from Acquia helps fund testing for Drupal Acquia logo

Comments

zanix’s picture

zanix’s picture

maximpodorov’s picture

Status: Active » Fixed

This is fixed in the commit:
http://cgit.drupalcode.org/field_default_token/commit/?id=c0be10f4a7d7bd...

Please reopen the issue if the problem remains.

Status: Fixed » Closed (fixed)

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