Recoverable fatal error: Argument 2 passed to token_replace() must be an array, string given, called in /var/www/sites/all/modules/swfupload/swfupload.module on line 206 and defined in function token_replace() (line: 79 in file /var/www/digitol.cz/digitol.cz/includes/token.inc).

I had to comment that line and module became working on one of sites (other site had no problems - probably lower error_reporting)

CommentFileSizeAuthor
#4 patch_fix_token.patch903 bytesShellingfox

Comments

intrafusion’s picture

I can confirm this issue, to get it working for me I replaced:

// Replace tokens.
if (module_exists('token')) {
  $file->file_path = token_replace($file->file_path, 'user');
}

With:

// Replace tokens.
if (module_exists('token')) {
  global $user;
  $file->file_path = token_replace($file->file_path, array('user' => $user));
}

However I'm not 100% sure this is the correct code for replacements as I'm using the tokens in my project

intrafusion’s picture

I can confirm that this issue is present, I replaced:

// Replace tokens.
if (module_exists('token')) {
  $file->file_path = token_replace($file->file_path, 'user');
}

With

// Replace tokens.
if (module_exists('token')) {
  global $user;
  $file->file_path = token_replace($file->file_path, array('user' => $user));
}

Which fixes it for me so that the module works, but I'm not sure that this would be correct to get the right replacements as I'm not using the token module

broncomania’s picture

Solved my problem also

Shellingfox’s picture

StatusFileSize
new903 bytes

This is the patch create follow #2, also t fix uninstall error of swfupload

poorva’s picture

Perfect !!! Works like a charm.
Thanks

dave reid’s picture

Status: Active » Needs work

This is not correct. You do not need to provide $global user to token_replace(). Users should be using the [current-user:*] tokens that work automatically.

emcniece’s picture

Yeah, that's a pretty interesting fix. Global $user seems to print out the currently logged-in user (admin, my case) each time, even if I'm editing another user's profile.

zwerg’s picture

Issue summary: View changes

There is an error with the $user variable. This patch doesn't work for me:
Notice: Undefined property: stdClass::$filepath in swfupload_swfupload() (Zeile 206 von /var/www/mysite/sites/all/modules/swfupload/swfupload.module).