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().
Comment | File | Size | Author |
---|---|---|---|
#1 | field_default_token-token_replace-expects-string-2188677-1.patch | 777 bytes | zanix |
Comments
Comment #1
zanixComment #2
zanixSeems to be related to these issues
#2341141: strpos() expects parameter 1 to be string
#2301669: Doesn't work with Tablfield
Comment #3
maximpodorov CreditAttribution: maximpodorov commentedThis is fixed in the commit:
http://cgit.drupalcode.org/field_default_token/commit/?id=c0be10f4a7d7bd...
Please reopen the issue if the problem remains.