How to use tokens in php code of the rules module?
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();
  }
}