How do I use the Drupal 7 API to change ownership of a comment This function function node_assign_owner_action() is provided by the Drupal 7 API to allow modules change node ownership,

I've searched, but not found a similar function that let me change the ownership of comments. Does anyone know how to change ownership of a comment without hacking the {comment} table directly, and without breaking existing incoming links?

I know that I can update the fields {comment}.uid, {comment}.name and {comment}.mail with the appropriate values, but as I understand things, contributed modules should never update tables "owned" by another module directly.

The only method I've found so far is to recreate the comment under new ownership.  This is not a good solutions because it will invalidate all incoming links that used the permalink associated with the original comment.
This changes the comment author details using the core comment API:

$cid = 12; // e.g get from db_select
$comment = comment_load($cid);
$comment-&gt;uid = 1;
$comment-&gt;name = 'admin';
$comment-&gt;mail = 'admin@example.com';
comment_save($comment);


You could also do something similar with a Rules component for use with VBO.