I was receiving this error when enabling the seo feature to print the comments in the page:

Notice: Undefined property: stdClass::$data in _fb_social_comments_seo() (line 288 of sites/all/modules/fb_social/plugins/fb_plugin/comments.inc).

Warning: Invalid argument supplied for foreach() in _fb_social_comments_seo_view() (line 301 of sites/all/modules/fb_social/plugins/fb_plugin/comments.inc).

This was only happening on pages without comments. The functions were not checking for null values. The fix I implemented is below. All I did was check if the variables existed via isset. I am not familiar with generating patches, if someone more experienced could take care of that it would be great.

Line 288

if(isset($result->$url->data)) {
      $comments = _fb_social_comments_seo_view($result->$url->data);
} else {
$comments = "";
}

Line 301:

if(isset($comments)) {
foreach ($comments as $comment) {
$result .= '<li>' . fb_social_comments_seo_comment_view($comment);
if (isset($comment -> comments)){
$result .= '<ul>';
foreach ($comment -> comments -> data as $subcomment) {
$result .= '<li>' . fb_social_comments_seo_comment_view($subcomment) . '</li>';
}
$result .= '</ul>';
}
$result .= '</li>';
}
}
Files: 

Comments

Actually the problem seems to be that Facebook changed the structure of the returned JSON.
One simple line fixed this for me:

Line 288 - Original

<?php
$comments
= _fb_social_comments_seo_view($result->$url->data);
?>

Line 288 - Fix:
<?php
$comments
= _fb_social_comments_seo_view($result->$url->comments->data);
?>

StatusFileSize
new716 bytes

Right, gave this patch thingy a try, please correct me if I did it wrong.

Status:Active» Reviewed & tested by the community

I had the same issue. The above patch fixed it.

Version:7.x-2.0-beta4» 7.x-2.x-dev
Status:Reviewed & tested by the community» Needs work

patch does not apply.

Status:Needs work» Reviewed & tested by the community
StatusFileSize
new604 bytes

Rerolled.

Confirmed that this is taken care of in 7.x-2.x-dev. Can we get this pushed to a non-dev version?

I was running the fb_social dev version and the patch still applied

This worked perfect for me, thanks!

Issue summary:View changes

After nullify $comments if $result->$url->data is not set, otherwise return $comments gives error.

Issue summary:View changes

There might be times when $comments is not defined.

add the following to top of function:

// initialize
  $comments = array();

Committed , thanks !

  • Commit caf13e0 on 7.x-2.x by ferdi: Issue #1485838 by klausi, johnzzon | michaelfillier: Comments SEO does...

  • Commit 3315ebf on 6.x-2.x by ferdi: Issue #1485838 by klausi, johnzzon | michaelfillier: Comments SEO does...

Status:Reviewed & tested by the community» Fixed