WordPress.org

Ready to get started?Download WordPress

Forums

Disqus Comment System
Disqus Missing argument 2 for wpdb::prepare() (4 posts)

  1. masonjames
    Volunteer Moderator
    Posted 7 months ago #

    Hiya folks,

    Got the following message in php error logs:
    Missing argument 2 for wpdb::prepare(), called in ../wp-content/plugins/disqus-comment-system/disqus.php on line 285

    The above error is generating high mysql resource and has caused a site to go offline a couple times.

    The fix is pretty simple, just replace curly bracket with %.

    The following is what we have done to fix the issue:
    https://github.com/theWPValet/disqus-wordpress/commit/9a57e56b70472cbde4275fc1e940648c968ad636

    // and follow up using legacy Disqus agent
              if (!$commentdata) {
     -            $commentdata = $wpdb->get_row($wpdb->prepare( "SELECT comment_ID, comment_parent FROM $wpdb->comments WHERE comment_agent = 'Disqus/1.0:{$comment->id}' LIMIT 1"), ARRAY_A);
     +            $commentdata = $wpdb->get_row($wpdb->prepare( "SELECT comment_ID, comment_parent FROM $wpdb->comments WHERE comment_agent = 'Disqus/1.0:%s' LIMIT 1", $comment->id), ARRAY_A);
              }

    We'd love to see it incorporated into the plugin to prevent the need for maintaining a separate version. Thanks!

    http://wordpress.org/plugins/disqus-comment-system/

  2. aldon
    Member
    Posted 5 months ago #

    i have the same error.

    i make the fix on disqus.php but now in error_log appears this error:

    [30-Jan-2014 09:25:15] WordPress database error You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near '1223137252'' LIMIT 1' at line 1 for query SELECT comment_ID, comment_parent FROM wp_comments WHERE comment_agent = 'Disqus/1.0:'1223137252'' LIMIT 1 made by do_action_ref_array, call_user_func_array, dsq_sync_forum, dsq_sync_comments

    [30-Jan-2014 09:25:15] WordPress database error You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near '1223138146'' LIMIT 1' at line 1 for query SELECT comment_ID, comment_parent FROM wp_comments WHERE comment_agent = 'Disqus/1.0:'1223138146'' LIMIT 1 made by do_action_ref_array, call_user_func_array, dsq_sync_forum, dsq_sync_comments

    [30-Jan-2014 09:25:15] WordPress database error You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near '1223138970'' LIMIT 1' at line 1 for query SELECT comment_ID, comment_parent FROM wp_comments WHERE comment_agent = 'Disqus/1.0:'1223138970'' LIMIT 1 made by do_action_ref_array, call_user_func_array, dsq_sync_forum, dsq_sync_comments

  3. Spectacula
    Member
    Posted 5 months ago #

    The above fix is almost right but needs to be %d not %s. %s will wrap the replacement in single quotes that'll break the quotes the %s is inside of, %d on the other hand won't use quotes and is the most appropriate for a comment ID anyway.

  4. aldon
    Member
    Posted 5 months ago #

    thanks you Spectacula!

Reply

You must log in to post.

About this Plugin

About this Topic

Tags

No tags yet.