• 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.

Viewing 15 replies - 1 through 15 (of 17 total)
  • 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.

    Thread Starter jazbek

    (@jazbek)

    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.

    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.

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

    Replace . number_format_i18n( get_comments_number() ) .

    With . "NA" .

    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'] );
    ...

    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.

    evanw,

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

    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/

    Worked here as well. Thanks evanw!

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

    It worked for me, thank you!

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

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

    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

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

Viewing 15 replies - 1 through 15 (of 17 total)
  • The topic ‘[Plugin: Disqus Comment System] PHP warnings after upgrading to wp 3.1’ is closed to new replies.