Hi,
get this error upon upgrade to 6.x-1.17,
Stephen :)

Warning: preg_match_all() expects parameter 2 to be string, array given in token_scan() (line 701 of /www/sr12/www-drupal/drupal.sanger.ac.uk/htdocs/sites/all/modules/contrib/token/token.module).

Comments

stephenrobinson’s picture

Hi,
Heres the debug:

function token_scan($text, $leading = TOKEN_PREFIX, $trailing = TOKEN_SUFFIX) {
  drupal_set_message('text<pre>' . htmlspecialchars(print_r($text,1)) . '</pre>');
  drupal_set_message('leading<pre>' . htmlspecialchars(print_r($leading,1)) . '</pre>');
  drupal_set_message('trailing<pre>' . htmlspecialchars(print_r($trailing,1)) . '</pre>');

    * text

      Array
      (
          [0] => <page-title>
      )

    * leading

      [

    * trailing

      ]

    * text

      Array
      (
          [0] => <page-title>
      )

    * leading

      [

    * trailing

      ]
stephenrobinson’s picture

Hi,
Can be fixed like this:

function token_scan($text, $leading = TOKEN_PREFIX, $trailing = TOKEN_SUFFIX) {
  if(is_array($text)){
    $text=$text[0];
  }
MasterChief’s picture

Same problem.

The patch in #2 works.

jdln’s picture

Im having the same issue. How do I apply the solution from #2? Do I add that code to token.module?
Thanks

dave reid’s picture

Status: Needs work » Closed (works as designed)

This needs to be fixed in modules calling token_replace() as they should not be providing an array here. See #1307890: token_replace() performance when there are no tokens.

aitala’s picture

Actually this sounds like its a PHP5.3 issue… and my webhost will not de-grade to 5.2.

Eric

dave reid’s picture

I have added some debugging code to 6.x-1.x-dev release that will help trace what function is responsible for calling this incorrectly. Please download the 6.x-1.x-dev release in about 12 hours to help me debug this further.

fzipi’s picture

Version: 6.x-1.17 » 6.x-1.18

The custom_breadcrumbs_nodeapi() function called token replacement with an array rather than a string for $text in /var/www/drupal/sites/all/modules/token/token.module on line 263.

See http://drupal.org/node/1327960. Applied their patch, and solved.

Marko B’s picture

reporting the same problem on 6.18 and 5.2 php, went back to 6.16 and there is no problem.