Skip to content

Commit

Permalink
Admin: Stop IMAP AJAX response from hanging by clearing the current s…
Browse files Browse the repository at this point in the history
…ession.

This only occurs if a 3rd-party plugin is opening a PHP session with
session_start() without closing the session properly.  What happens if the
session isn't closed is all subsequent AJAX responses and browser requests
will hang since our IMAP inbox check is still running in the background.

Thanks to this Stack Overflow article for helping me out:
http://stackoverflow.com/a/9906646

If you wrote a plugin that does this, you are forever on my naughty list.
Thanks for wasting my precious time!

See #40.
  • Loading branch information
r-a-y committed Mar 14, 2017
1 parent 424b2c0 commit e6828ce
Showing 1 changed file with 10 additions and 0 deletions.
10 changes: 10 additions & 0 deletions includes/bp-rbe-admin.php
Original file line number Diff line number Diff line change
Expand Up @@ -244,6 +244,16 @@ function(response) {
public function ajax_connect() {
check_ajax_referer( 'bp_rbe_ajax_connect' );

/*
* Stupid WordPress plugins using session_start() without closing the session
* properly.
*
* @link http://stackoverflow.com/a/9906646 Thanks for the hint!
*/
if ( session_id() ) {
session_write_close();
}

// Run IMAP inbox check.
bp_rbe_run_inbox_listener( array( 'force' => true ) );
}
Expand Down

0 comments on commit e6828ce

Please sign in to comment.