Skip to content

Commit

Permalink
Admin: For IMAP AJAX connection check, if there is an error, properly…
Browse files Browse the repository at this point in the history
… fetch the error.

In order to fetch the error, we need to revoke the IMAP connection to
grab the error for output.

See #40.
  • Loading branch information
r-a-y committed Mar 11, 2017
1 parent 8eb53f5 commit 05742f4
Showing 1 changed file with 12 additions and 3 deletions.
15 changes: 12 additions & 3 deletions includes/bp-rbe-admin.php
Original file line number Diff line number Diff line change
Expand Up @@ -261,9 +261,18 @@ public function ajax_connect_notice() {
'msg' => __( '<strong>Reply By Email</strong> is currently <span>CONNECTED</span> and checking your inbox continuously.', 'bp-rbe' )
) );
} else {
wp_send_json_success( array(
'msg' => sprintf( __( 'Error: Unable to connect to inbox - %s', 'bp-rbe' ), join( '. ', (array) imap_errors() ) )
) );
// If we're here, check connection for errors.
$imap = BP_Reply_By_Email_Connect::init();
if ( false === $imap ) {
wp_send_json_error( array(
'msg' => sprintf( __( 'Error: Unable to connect to inbox - %s', 'bp-rbe' ), join( '. ', (array) imap_errors() ) )
) );

// We shouldn't be here, so close the connection and die.
} else {
imap_close( $imap );
die();
}
}
}

Expand Down

0 comments on commit 05742f4

Please sign in to comment.