WordPress.org

Ready to get started?Download WordPress

Forums

Disqus Comment System
PHP warnings after upgrading to wp 3.1 (18 posts)

  1. jazbek
    Member
    Posted 3 years ago #

    Getting this on each post listing in wp-admin, under the comments column:

    Warning: number_format() expects parameter 1 to be double, string given in /path/to/wp/wp-includes/functions.php on line 156

    If I deactivate disqus, the error goes away. Re-activate and it comes back. I also uninstalled disqus and re-installed, that did not fix it.

    I echo'd the arg that's being passed to number_format() and it is indeed a "number" but I guess it's typed as a string instead of a double.

  2. pszeinert
    Member
    Posted 3 years ago #

    I'm getting the same error. Good insight into the problem. I am working on a work around because it appears that it only affects the admin panel. I don't want to inconvenience our users, so I have asked our admins to put up with it until I can code a fix. Hopefully Disqus will beat me to it.

  3. jazbek
    Member
    Posted 3 years ago #

    I emailed disqus support yesterday and they wrote back and said they were not seeing the same problem in their tests with WP 3.1. I did some more troubleshooting at their suggestion (turned off all other plugins and removed my custom theme), and it was still happening. I let them know and sent them a screenshot; still waiting for them to get back to me with a 2nd reply. I will post again when I hear something.

  4. evanw
    Member
    Posted 3 years ago #

    I'm having the exact same problem. It's something to do with how Disqus pulls comments.

    The actual error is being thrown in /wp-admin/includes/class-wp-list-table.php on line 423:

    echo "<a href='" . esc_url( add_query_arg( 'p', $post_id, admin_url( 'edit-comments.php' ) ) ) . "' title='" . esc_attr( $pending_phrase ) . "' class='post-com-count'><span class='comment-count'>" . number_format_i18n( get_comments_number() ) . "</span></a>";

    And if you replace . number_format_i18n( get_comments_number() ) . with . "N/A" .` you can at least temporarily fix the problem (although I highly recommend not messing with the WordPress core files.

    I hope Disqus can fix this soon.

  5. evanw
    Member
    Posted 3 years ago #

    My formatting didn't work there. The temporary fix:

    Replace . number_format_i18n( get_comments_number() ) .

    With . "NA" .

  6. evanw
    Member
    Posted 3 years ago #

    You can also optionally cast $number to a double in wp-includes/functions.php to temporarily fix the problem.

    i.e.

    function number_format_i18n( $number, $decimals = 0 ) {
    	global $wp_locale;
            $number = (double)$number;
    	$formatted = number_format( $number, absint( $decimals ), $wp_locale->number_format['decimal_point'], $wp_locale->number_format['thousands_sep'] );
    ...
  7. evanw
    Member
    Posted 3 years ago #

    Ok, I have a better fix, ignore the last ones!

    In /wp-content/plugins/disqus-comments/system/disqus.php, go to line 693 (or somewhere near there) and find:

    // Mark entries in index to replace comments link.
    function dsq_comments_number($count) {
        global $post;
    
    	if ( dsq_can_replace() ) {
    		return '<span class="dsq-postid" rel="'.htmlspecialchars(dsq_identifier_for_post($post)).'">'.$count.'</span>';
    	} else {
    		return $count;
    	}
    }

    And replace it with:

    // Mark entries in index to replace comments link.
    function dsq_comments_number($count) {
        global $post;
    	return $count;
    }

    And to be safe, find the function that starts with:

    function dsq_comments_text($comment_text) {

    And replace it with:

    function dsq_comments_text($comment_text) {
    	global $post;
    	$number_of_comments = get_comments_number();
    
    	return $number_of_comments;
    }

    The problem seems to be in funciton dsq_comments_number, it was returning a bunch of html to format and label the comments which would obviously break WordPress's built-in number formatting, even if it was converted to a double.

  8. pszeinert
    Member
    Posted 3 years ago #

    evanw,

    I have implemented your fix on two sites and everything seems to be working fine now. Great job!

  9. evanw
    Member
    Posted 3 years ago #

    Glad it helped! I did a full write-up here if you want more explanation as to what I think was happening: http://www.techerator.com/2011/02/fix-wordpress-3-1-and-disqus-plugin-error-when-returning-comments-count/

  10. revolutionaut
    Member
    Posted 3 years ago #

    Worked here as well. Thanks evanw!

  11. fermanaziz
    Member
    Posted 3 years ago #

    i was facing same problem, so i reactivated the older version of disqus until they solve the issue

  12. camilodelvasto
    Member
    Posted 3 years ago #

    It worked for me, thank you!

  13. groan
    Member
    Posted 3 years ago #

    SWEET, I hope they come out with a fix soon. I don't wnat to have to do this for all my sites!

  14. farhanfaisal
    Member
    Posted 3 years ago #

    u're super cool, evanw.. thanks.. solved the problem..

  15. phpdeveloper
    Member
    Posted 3 years ago #

    Hello
    I am working on a wp blog site where I am using Disqus Version 2.61 with wp version 3.1

    My disqus Export comments to Disqus and Sync Disqus with WordPress section is working fine. So I think that I am using correct KEYS.

    But still I am not able to populate comment box on my blog page. So that no one can comment on my blog.

    Please help me if their is any problem in discus version with wordpress version? or any thing else?

    yaa I have installed same environment on my demo server and its working fine their.

    please help, its urgent!!!!

    Thanks

  16. blackstudio
    Member
    Posted 3 years ago #

    evanw!! you the man!! worked a treat!!

  17. ben4d85
    Member
    Posted 3 years ago #

    Thank you, ewanw!

    Does anyone know why Disqus still hasn't fixed this? Apparently the last update was 2010-12-4...

  18. Alison Barrett
    Member
    Posted 3 years ago #

    Thanks for this fix! Worked like a charm.

Topic Closed

This topic has been closed to new replies.

About this Plugin

About this Topic