[buddypress-trac] [BuddyPress Trac] #7506: friends_add_friend() should convert accepted arguments
buddypress-trac
noreply at wordpress.org
Tue Apr 18 21:42:49 UTC 2017
#7506: friends_add_friend() should convert accepted arguments
--------------------------+-----------------------------
Reporter: slaFFik | Owner:
Type: defect (bug) | Status: new
Priority: normal | Milestone: Awaiting Review
Component: Friends | Version:
Severity: normal | Keywords:
--------------------------+-----------------------------
Currently when in code you do something like this:
{{{#!php
friends_add_friend( $user_one, $user_two, true );
}}}
where `$user_one` and `$user_two` are like this: `string(1)"1"` - the
success email won't be sent to `$initiator_id`.
Reason: a kind-of-broken logic in `BP_Email_Recipient::_construct()`,
where we check `$email_or_user`. Because of this token for
`recipient.email` is not generated and `bp_email_set_default_headers()`
generates notices.
So there should be several improvements:
1. `friends_add_friend()` should `intval()` its arguments.
2. `BP_Email_Recipient::_construct()` should be aware (or degrade
gracefully) of a user id coming as a string, not an integer. Perhaps,
`is_numeric()` instead of `is_int()` check?
3. `bp_email_set_default_headers()` should have `$user` check to prevent
generating those notices in case user ID is a string passed to
`bp_send_email()`, because `$user->ID` doesn't exist.
--
Ticket URL: <https://buddypress.trac.wordpress.org/ticket/7506>
BuddyPress Trac <http://buddypress.org/>
BuddyPress Trac
More information about the buddypress-trac
mailing list