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

    https://www.ads-software.com/plugins/disqus-comment-system/

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

    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.

    thanks you Spectacula!

Viewing 3 replies - 1 through 3 (of 3 total)
  • The topic ‘Disqus Missing argument 2 for wpdb::prepare()’ is closed to new replies.