Skip to content

Commit

Permalink
correct is_duplicate_comment logic
Browse files Browse the repository at this point in the history
  • Loading branch information
jondavidjohn committed May 17, 2013
1 parent 08f9d23 commit 0ca3c1c
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 7 deletions.
7 changes: 4 additions & 3 deletions lib/social/service.php
Expand Up @@ -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) {
Expand Down
8 changes: 4 additions & 4 deletions lib/social/service/facebook.php
Expand Up @@ -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;
Expand All @@ -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));
Expand Down

0 comments on commit 0ca3c1c

Please sign in to comment.