diff --git a/lib/social/service.php b/lib/social/service.php index 581f3a5d..b5bf14aa 100755 --- a/lib/social/service.php +++ b/lib/social/service.php @@ -688,9 +688,10 @@ public function is_duplicate_comment($post, $result_id) { $results = $wpdb->get_results($wpdb->prepare(" SELECT meta_value - FROM $wpdb->commentmeta - WHERE comment_id = %s - AND meta_key = 'social_status_id' + FROM $wpdb->commentmeta AS cm, $wpdb->comments AS c + WHERE cm.comment_id = c.comment_ID + AND c.comment_post_id = %s + AND cm.meta_key = 'social_status_id' ", $post->ID)); foreach ($results as $result) { diff --git a/lib/social/service/facebook.php b/lib/social/service/facebook.php index 76c2b75d..c1ea40e3 100755 --- a/lib/social/service/facebook.php +++ b/lib/social/service/facebook.php @@ -365,15 +365,15 @@ public function save_aggregated_comments(&$post) { } // sanity check to make sure this comment is not a duplicate - if ($this->is_duplicate_comment($post, $result->id)) { + if ($this->is_duplicate_comment($post, $result_id)) { Social::log('Result #:result_id already exists, skipping.', array( - 'result_id' => $result->id + 'result_id' => $result_id ), 'duplicate-comment'); continue; } Social::log('Saving #:result_id.', array( - 'result_id' => (isset($result->status_id) ? $result->status_id : $result->id) + 'result_id' => $result_id )); $comment_id = 0; @@ -386,7 +386,7 @@ public function save_aggregated_comments(&$post) { update_comment_meta($comment_id, 'social_account_id', addslashes_deep($user_id)); update_comment_meta($comment_id, 'social_profile_image_url', addslashes_deep('https://graph.facebook.com/'.$user_id.'/picture')); - update_comment_meta($comment_id, 'social_status_id', addslashes_deep((isset($result->status_id) ? $result->status_id : $result->id))); + update_comment_meta($comment_id, 'social_status_id', addslashes_deep($result_id)); if (!isset($result->raw)) { $result = (object) array_merge((array) $result, array('raw' => $result));