Support » Fixing WordPress » wp-comments-post.php very slow (problematic function identified)

  • Resolved Mr. Z


    The following procedure in wp-comments-post.php is hanging for about 2 minutes whenever a comment is posted by a user NOT logged in (no problem if logged-in):

    $comment = wp_handle_comment_submission( wp_unslash( $_POST ) );
    if ( is_wp_error( $comment ) ) {
            $data = intval( $comment->get_error_data() );
            if ( ! empty( $data ) ) {
                    wp_die( '<p>' . $comment->get_error_message() . '</p>', __( 'Comment Submission Failure' ), array( 'response' => $data, 'back_link' => true ) );
            } else {

    I’ve isolated the problem to this procedure using a timer_stop() function. Less than a second before it, more than two minutes after.

    Suggestions? Help?


Viewing 9 replies - 1 through 9 (of 9 total)
  • It hangs specifically on

    $comment = wp_handle_comment_submission( wp_unslash( $_POST ) );

    Moderator t-p


    As the adage goes, don’t modify core files (unless you know what you are doing in there and are aware of the limitations and drawbacks this imposes). Modifications can cause security risks, performance degradation, broken plugins/themes, you will lose all changes when you next update the WordPress, etc.

    Instead of modifying the core file, try the basic troubleshooting steps to narrow down the issue:
    – deactivating ALL (yes all) plugins temporarily to see if this resolves the problem (plugin functions can interfere). If this works, re-activate them individually (one-by-one) to find the problematic plugin(s).
    – switching to the unedited default Theme (Twenty Seventeen.) for a moment using the WP dashboard to rule out any theme-specific issue (theme functions can interfere like plugins).

    I didn’t modify the core file.

    Edited to add: I did – I admit – create an option called mytimer and the moved the following line of code around the core file to isolate the problematic function:


    Disabling (all) plugins doesn’t help.

    Changing to default theme (2017) and deactivating all plugins doesn’t help. I was going to wait until late night to try this but, since I have your attention, I just tried it.

    • This reply was modified 3 years, 1 month ago by Mr. Z. Reason: added something

    ubuntu 16.04

    Seems resolved. Server hostname was not a FQDN. Corrected that and anonymous comments now post immediately. Don’t understand why that caused the problem…

    Moderator t-p


    Glad to know it 🙂

    Prayag Verma


    I faced a similar issue. In my case, the problem was with a plugin called – WP-Mail-SMTP – . The moment I disabled this plugin, the comment submission stopped hanging. I am using WordPress 4.8.1

    I had a similar problem where there was a delay up to 20 seconds after adding a comment before the page fully rendered. In my case removing the “Subscribe to Double-Opt-In Comments” plug in fixed it.

    @mr-z-1 You said server hostname was not a FQDN. How exactly did you resolve this? I also tried disabling all the plugins but it didn’t help.

Viewing 9 replies - 1 through 9 (of 9 total)
  • The topic ‘wp-comments-post.php very slow (problematic function identified)’ is closed to new replies.