Skip to:
Content

BuddyPress.org

Opened 4 years ago

Closed 4 years ago

#6894 closed defect (bug) (fixed)

BP Messages - Causes PHP Error - Wrong call of a function

Reported by: Jon Ziemlich Owned by: r-a-y
Milestone: 2.4.4 Priority: normal
Severity: normal Version: 2.4.0
Component: Messages Keywords: has-patch
Cc:

Description

FIX: Remove line 104 at bp-messages/bp-messages-actions.php: $feedback = $send->get_error_message();

Hey there,

bp-messages/bp-messages-actions.php on line 104:

$feedback = $send->get_error_message();

The Variable $send is defined on line 87 $send = messages_new_message( ... .

The function messages_new_message is defined in bp-messages/bp-messages-functions.php

This function returns in no case an object. Only an int or bool.
So line 104 at bp-messages/bp-messages-actions.php is wrong and causes errors!

Thank you.

Best wishes
Jon Ziemlich

Attachments (1)

6894.01.patch (1.9 KB) - added by r-a-y 4 years ago.

Download all attachments as: .zip

Change History (8)

#1 @DJPaul
4 years ago

  • Cc bp-messages-actions.php removed
  • Priority changed from highest to normal
  • Severity changed from blocker to normal

Thank you for the report, @Jon Ziemlich.

How exactly are you causing this to fail? How did you discover the problem?

#2 @Jon Ziemlich
4 years ago

Sorry i saw now, that in some cases WP_Error Objects are returned. I will test it and send you as i know more.

#3 @boonebgorges
4 years ago

See [10286].

It does appear that there's one situation where a failed message post may result in false being returned: when $message->send() fails for a miscellaneous reason (such as a database error) near the end of messages_new_message(). @r-a-y we should probably do an error_type check here, right? Can we write a test that triggers this kind of failure?

#4 @r-a-y
4 years ago

  • Keywords has-patch added; needs-patch removed
  • Version set to 2.4.0

Ugh... my bad!

Attached patch should fix the issue.

Jon - Can you test the patch and see if that fixes the issue for you?

Last edited 4 years ago by r-a-y (previous) (diff)

@r-a-y
4 years ago

#5 @r-a-y
4 years ago

Received a report that the patch works.

Going to commit.

#6 @r-a-y
4 years ago

In 10585:

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.

See #6894 (trunk).

#7 @r-a-y
4 years ago

  • Owner set to r-a-y
  • Resolution set to fixed
  • Status changed from new to closed

In 10586:

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).

Note: See TracTickets for help on using tickets.