How to use tokens in php code of the rules module? I'm using Ajax_comments to add comments on nodes without having to reload the page on save. Now the "node history" doesn't get updated which throws off the "new comment" count.

I tried to create a rule to update the node history on "comment save". Seems like my only option is to execute PHP code. How do I combine PHP code with tokens to get something like this:

if ([current-user:uid]) {
   db_merge('history')
     -&gt;key(array(
       'uid' =&gt; [current-user:uid],
       'nid' =&gt; [comment:node:nid],
     ))
     -&gt;fields(array('timestamp' =&gt; [site:current-date]))
     -&gt;execute();
  }
It turns out that the above code works when I turn of the Ajax Comments module. With that module, it throws an internal server error.

I reported it as issue. 

This hook does the job now:

function hook_comment_insert($comment) {
  //dpm($comment);

  if ($comment-&gt;uid) {
   db_merge('history')
     -&gt;key(array(
       'uid' =&gt; $comment-&gt;uid,
       'nid' =&gt; $comment-&gt;nid,
     ))
     -&gt;fields(array('timestamp' =&gt; REQUEST_TIME))
     -&gt;execute();
  }
}