• My hosting company recently turned on the error reporting for slow queries in php/apache and we have seen the error logs get flooded with errors all from queries requesting spam comments on the front end of the site. We are using akismet to catch the spam, which is working just fine. The referrers are all coming from blog posts, and you can see an example of the error below (I have changed details of the log for security & anonymity.)

    LONG QUERY (1199 characters long generated in /nas/wp/www/cluster-1847/INSTALL_NAME/wp-comments-post.php:134):
        SELECT comment_ID FROM wp_999_comments
        WHERE comment_post_ID = 233
        AND comment_parent = '0'
        AND comment_approved != 'trash'
        AND ( comment_author = 'SpamAuthor' OR comment_author_email = '[email protected]' )
        AND comment_content = 'A WHOLE BUNCH OF SPAM HERE'
        LIMIT 1, referer: http://www.example.com/2013/05/23/some_post/

    I can’t figure out for the life of me why this query would be running on the front end of the site. I don’t understand why WordPress would even be querying spam comments here. I tried to modify the query using the filter below, but it did not work at all.

    function prefix_comments_mod( $comments ) {
    
    	$comments->query_vars['status'] = 'approve';
    
    }
    add_filter( 'pre_get_comments', 'prefix_comments_mod' );

    Has anyone seen this sort of error before / have a fix for it?

Viewing 3 replies - 1 through 3 (of 3 total)
  • An answer on this would be great! I have the same problem. My hosting is wpengine.com.
    Error logs are full of LONG QUERY warnings from spam comments

    dimetrodon

    (@dimetrodon)

    Long Query

    When you see an entry in the log that looks similar to this

    [Wed Mar 26 06:26:19 2014] [error] [client 127.0.0.1] LONG QUERY: SELECT DISTINCT user.ID AS user_id, t.* FROM …

    We have included it in the log to signify that the length of the query, which would be over 1,024 characters, is a Long Query and may be able to be optimized. We did not take any action on this query, it is just a notice to our customers. These only apply to Select statements, and not any other type of statements.

    http://wpengine.com/support/long-query-killed-query-error-logs/

    Thread Starter Ryan Kanner

    (@ryankanner)

    ok, but in our case we have many sites running on a multisite install, so the error log has become completely unusable for any sort of monitoring. I’m also baffled why this query would be running on the front end of the site. It shouldn’t be looking for spam comments at all.

Viewing 3 replies - 1 through 3 (of 3 total)

The topic ‘Long query apache error from spam comments’ is closed to new replies.