You are here

public function WordPressComment::prepare in WordPress Migrate 7

Same name and namespace in other branches
  1. 7.2 wordpress_comment.inc \WordPressComment::prepare()

Prepare comment - called just before comment_save().

Parameters

stdClass $comment:

stdClass $row:

File

./wordpress_comment.inc, line 156
Support for migrating comments from a WordPress blog into Drupal.

Class

WordPressComment
Implementation of WordPressMigration, for comments

Code

public function prepare(stdClass $comment, stdClass $row) {

  // Match creator email to Drupal account if possible; otherwise, use anonymous
  static $drupal_static_fast;
  if (!isset($drupal_static_fast)) {
    $drupal_static_fast['user_map'] =& drupal_static(__FUNCTION__);
  }
  $user_map =& $drupal_static_fast['user_map'];
  if (!isset($user_map[$row->comment_author_email])) {
    $user_map[$row->comment_author_email] = db_select('users', 'u')
      ->fields('u', array(
      'uid',
    ))
      ->condition('mail', $row->comment_author_email)
      ->execute()
      ->fetchField();
    if (!$user_map[$row->comment_author_email]) {
      $user_map[$row->comment_author_email] = 0;
    }
  }
  $comment->uid = $user_map[$row->comment_author_email];
}