Skip to:
Content

Opened 3 years ago

Closed 3 years ago

Last modified 3 years ago

#7055 closed defect (bug) (fixed)

Emails: Attempting to use bp_send_mail() on non-root blogs fails

Reported by: r-a-y Owned by: r-a-y
Milestone: 2.5.3 Priority: normal
Severity: normal Version: 2.5.0
Component: Emails Keywords: dev-feedback has-patch
Cc:

Description (last modified by r-a-y)

When a dev tries to use bp_send_email() on a non-root blog, bp_send_email() will throw the missing_email WP error.

In bp_send_email(), we attempt to use switch_to_blog() to tell WordPress to use all BP root blog settings, however switch_to_blog() doesn't work that way, it only switches the WPDB DB prefixes.

See #WP20541 for more details.

To remedy this, we need to register the email type taxonomy even on non-root blogs.

I'm currently working around this by registering the email type taxonomy only on the blog in question and on $_POST requests to limit the exposure of the email taxonomy type.

Putting this in 2.6 since I don't think we can engineer a good solution before 2.5.3.

Attachments (1)

7055.01.patch (1.5 KB) - added by r-a-y 3 years ago.

Download all attachments as: .zip

Change History (6)

#1 @r-a-y
3 years ago

  • Description modified (diff)
  • Keywords has-patch added

Actually, since the taxonomy isn't public, we could just register the taxonomy at all times.

@r-a-y
3 years ago

#2 @DJPaul
3 years ago

  • Milestone changed from 2.6 to 2.5.3

Sounds good but please can you check bp_core->register_post_types to see if we need to do the same for the post type? I imagine the same problem is there.

If we can get this fixed within ~24 hours hours, we'll 2.5.3, otherwise 2.5.4 (or 2.6).

#3 @r-a-y
3 years ago

Sounds good but please can you check bp_core->register_post_types to see if we need to do the same for the post type? I imagine the same problem is there.

I've tested this and the email post type does not need to be registered network-wide because WP_Query::parse_query() doesn't do an explicit post_type_exists() check. Only the email taxonomy needs to be.

Going to commit.

#4 @r-a-y
3 years ago

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

In 10764:

Emails: Register our email type taxonomy at all times.

Fixes an issue where attempting to use bp_get_email() / bp_send_email()
on a non-root blog would fail.

In bp_get_email(), get_posts() is used to fetch our email post type.
Since we are doing a taxonomy query in get_posts(), WP_Tax_Query::clean_query
attempts to see if our taxonomy exists. Since our taxonomy did not exist on
non-root blogs, the taxonomy SQL clauses would not be added and
bp_get_email() would fail.

See #WP20541 for more details.

Fixes #7055 (2.5-branch)

#5 @r-a-y
3 years ago

In 10765:

Emails: Register our email type taxonomy at all times.

Fixes an issue where attempting to use bp_get_email() / bp_send_email()
on a non-root blog would fail.

In bp_get_email(), get_posts() is used to fetch our email post type.
Since we are doing a taxonomy query in get_posts(), WP_Tax_Query::clean_query
attempts to see if our taxonomy exists. Since our taxonomy did not exist on
non-root blogs, the taxonomy SQL clauses would not be added and
bp_get_email() would fail.

See #WP20541 for more details.

See #7055 (trunk)

Note: See TracTickets for help on using tickets.