token_replace(), inside token_filter_replacetoken() is called in the following way:

  $output = token_replace($token, $type, $object = NULL, $leading = '', $trailing = '');

The code actually assigns values to the $object, $leading, $trailing variables. This means that the variable $object will always be set to NULL whatever value it has been assigned to the variable before; that is also the value that token_replace() will get for its formal parameter $object.

The code should be:

  $output = token_replace($token, $type, $object, '', '');

Comments

avpaderno’s picture

Ping!

pvhee’s picture

Status: Active » Fixed

Thanks for spotting this, it has been fixed in HEAD. For some reason I wasn't subscribed anymore to issues in all my modules, so sorry for the delays.

avpaderno’s picture

Status: Fixed » Active

The call to token_replace() is still wrong: rather than calling it as token_replace($token, $type, $object, $leading = '[', $trailing = ']'), you should call it as token_replace($token, $type, $object, '[', ']'), or token_replace($token, $type, $object) ('[', ']' are the default values for the last two parameters, and they don't need to be used).

pvhee’s picture

Status: Active » Fixed

Wow, I'm quite ashamed I made that mistake :) Thanks, I fixed it right away! (leaving the '[', ']' for clarity)

avpaderno’s picture

You know, four eyes see better than two. :-)
Rather than calling it a mistake, I would call it a typo; mistakes are worse than that.

Status: Fixed » Closed (fixed)

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