You are here

function comment_node_convert_change in Node Convert 7

Implementation of node_convert_change().

File

modules/comment.node_convert_behavior.inc, line 13
Comment behavior.

Code

function comment_node_convert_change($data, $op) {
  if ($op == 'insert') {
    $node = $data['node'];
    $tables = array(
      'field_data_comment_body',
      'field_revision_comment_body',
    );
    foreach ($tables as $table) {
      $query = '
        UPDATE {' . $table . '} AS cb
        LEFT JOIN ' . '{comment} AS c ON cb.entity_id = c.cid AND cb.entity_type = :entity_type
        SET cb.bundle = :new_bundle
        WHERE c.nid = :nid
        ';
      $args = array(
        ':entity_type' => 'comment',
        ':nid' => $node->nid,
        ':new_bundle' => 'comment_node_' . $data['dest_node_type'],
      );
      db_query($query, $args);
    }
  }
}