Title: wp-comments-post.php very slow (problematic function identified)
Last modified: July 28, 2017

---

# wp-comments-post.php very slow (problematic function identified)

 *  Resolved [Mr. Z](https://wordpress.org/support/users/mr-z-1/)
 * (@mr-z-1)
 * [8 years, 10 months ago](https://wordpress.org/support/topic/wp-comments-post-php-very-slow-problematic-function-identified/)
 * 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 {
                       exit;
               }
       }
       ```
   
 * 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?
 * Thanks.

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

 *  Thread Starter [Mr. Z](https://wordpress.org/support/users/mr-z-1/)
 * (@mr-z-1)
 * [8 years, 10 months ago](https://wordpress.org/support/topic/wp-comments-post-php-very-slow-problematic-function-identified/#post-9361836)
 * It hangs specifically on
 * `$comment = wp_handle_comment_submission( wp_unslash( $_POST ) );`
 *  Moderator [t-p](https://wordpress.org/support/users/t-p/)
 * (@t-p)
 * [8 years, 10 months ago](https://wordpress.org/support/topic/wp-comments-post-php-very-slow-problematic-function-identified/#post-9361956)
 * 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).
 *  Thread Starter [Mr. Z](https://wordpress.org/support/users/mr-z-1/)
 * (@mr-z-1)
 * [8 years, 10 months ago](https://wordpress.org/support/topic/wp-comments-post-php-very-slow-problematic-function-identified/#post-9361964)
 * 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:
 * `update_option('mytimer',timer_stop());`
 * 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 8 years, 10 months ago by [Mr. Z](https://wordpress.org/support/users/mr-z-1/).
      Reason: added something
 *  Thread Starter [Mr. Z](https://wordpress.org/support/users/mr-z-1/)
 * (@mr-z-1)
 * [8 years, 10 months ago](https://wordpress.org/support/topic/wp-comments-post-php-very-slow-problematic-function-identified/#post-9361982)
 * ubuntu 16.04
    nginx php7
 *  Thread Starter [Mr. Z](https://wordpress.org/support/users/mr-z-1/)
 * (@mr-z-1)
 * [8 years, 10 months ago](https://wordpress.org/support/topic/wp-comments-post-php-very-slow-problematic-function-identified/#post-9361995)
 * 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](https://wordpress.org/support/users/t-p/)
 * (@t-p)
 * [8 years, 10 months ago](https://wordpress.org/support/topic/wp-comments-post-php-very-slow-problematic-function-identified/#post-9362088)
 * Glad to know it 🙂
 *  [Prayag Verma](https://wordpress.org/support/users/stylifyyourblog/)
 * (@stylifyyourblog)
 * [8 years, 10 months ago](https://wordpress.org/support/topic/wp-comments-post-php-very-slow-problematic-function-identified/#post-9379800)
 * I faced a similar issue. In my case, the problem was with a plugin called – WP-
   Mail-SMTP – [https://wordpress.org/plugins/wp-mail-smtp/](https://wordpress.org/plugins/wp-mail-smtp/).
   The moment I disabled this plugin, the comment submission stopped hanging. I 
   am using WordPress 4.8.1
 *  [kwdavids](https://wordpress.org/support/users/kwdavids/)
 * (@kwdavids)
 * [8 years, 4 months ago](https://wordpress.org/support/topic/wp-comments-post-php-very-slow-problematic-function-identified/#post-9879544)
 * 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.
 *  [wrip](https://wordpress.org/support/users/wrip/)
 * (@wrip)
 * [8 years, 2 months ago](https://wordpress.org/support/topic/wp-comments-post-php-very-slow-problematic-function-identified/#post-10107524)
 * [@mr-z-1](https://wordpress.org/support/users/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.

 * In: [Fixing WordPress](https://wordpress.org/support/forum/how-to-and-troubleshooting/)
 * 9 replies
 * 5 participants
 * Last reply from: [wrip](https://wordpress.org/support/users/wrip/)
 * Last activity: [8 years, 2 months ago](https://wordpress.org/support/topic/wp-comments-post-php-very-slow-problematic-function-identified/#post-10107524)
 * Status: resolved

## Topics

### Topics with no replies

### Non-support topics

### Resolved topics

### Unresolved topics

### All topics
