Skip to:
Content

BuddyPress.org


Ignore:
Timestamp:
02/12/2016 11:30:39 PM (9 years ago)
Author:
r-a-y
Message:

Messages: Return generic WP Error in messages_new_message() when necessary.

In #6535, we added an 'error_type' parameter in messages_new_message()
that supports returning a WP Error object if error type is set to
'wp_error'. However, we did not return a WP error further down in the
messages_new_message() function, which can result in a potential fatal
error to occur.

This commit rectifies this and includes a unit test.

Anti-props r-a-y.

Fixes #6894 (2.4-branch).

File:
1 edited

Legend:

Unmodified
Added
Removed
  • branches/2.4/src/bp-messages/bp-messages-functions.php

    r10304 r10586  
    175175
    176176    // Bail if message failed to send.
    177     if ( ! $message->send() ) {
     177    $send = $message->send();
     178    if ( false === is_int( $send ) ) {
     179        if ( 'wp_error' === $r['error_type'] ) {
     180            if ( is_wp_error( $send ) ) {
     181                return $send;
     182            } else {
     183                return new WP_Error( 'message_generic_error', __( 'Message was not sent. Please try again.', 'buddypress' ) );
     184            }
     185        }
     186
    178187        return false;
    179188    }
Note: See TracChangeset for help on using the changeset viewer.