WordPress.org

Support

Support » Plugins and Hacks » Comments Evolved for WordPress » [Resolved] Fatal error: Call to a member function find() on a non-object

[Resolved] Fatal error: Call to a member function find() on a non-object

  • Hey Brandon!

    On one of my sites I’m occasionally getting this error displaying on the front end of my site:

    Fatal error: Call to a member function find() on a non-object in /plugins/gplus-comments/includes/lib/frontend.php on line 87

    I’m running WP 3.6 and your Github revision 1.5.7.

    Any thoughts?

    ~ Chris

    http://wordpress.org/plugins/gplus-comments/

Viewing 4 replies - 1 through 4 (of 4 total)
  • Line 87 being:

    $count_raw = $link_body->find('#widget_bounds > span', 0);

    yea, its one of the comment services’s is returning an empty string/error instead of the correct data or a zero if there are none … and my silly persons has not put any error checking into that chunk of code yet to watch for it …. but before 1.5.8 is pushed i for sure will

    thanks

    yea , its a bit crude and I’ll fix it better in the next update but you can replace that whole line with this one below and it will check for that so it wont happen again when your server or google ( i’m guessing you server ) becomes to overwhelmed 😛 )


    if(!empty($link_body)) {
    $count_raw = $link_body->find('#widget_bounds > span', 0);
    }

    Cheers!

    So, this (the whole section):

    function comments_evolved_get_gplus_count($url = "") {
      include_once COMMENTS_EVOLVED_LIB . '/simple_html_dom.php';
      if(empty($url)){ $url = get_permalink(); }
      $link = 'https://apis.google.com/_/widget/render/commentcount?bsv&href=' . urlencode($url);
      $link_body = get_transient('ce_'.$link);
      if (false === $link_body) {
        $link_body = wp_remote_retrieve_body(wp_remote_get($link));
        set_transient('ce_'.$link, $link_body, 60);
      }
      $link_body = str_get_html($link_body);
      if(!empty($link_body)) {
      $count_raw = $link_body->find('#widget_bounds > span', 0);
    }
      $count_arr = split(" ",$count_raw->plaintext);
      return trim($count_arr[0]);
    }
Viewing 4 replies - 1 through 4 (of 4 total)
  • The topic ‘[Resolved] Fatal error: Call to a member function find() on a non-object’ is closed to new replies.
Skip to toolbar