Skip to:
Content

bbPress.org

Opened 7 years ago

Closed 7 years ago

Last modified 13 months ago

#3179 closed defect (bug) (fixed)

bbp_make_*_user() outputs error on non-multisite installations

Reported by: espellcaste's profile espellcaste Owned by: johnjamesjacoby's profile johnjamesjacoby
Milestone: 2.6 Priority: normal
Severity: normal Version: trunk
Component: Component - Users Keywords: needs-patch needs-unit-tests commit
Cc:

Description

While testing wp-cli-bbpress, I noticed that bbp_make_spam_user() and bbp_make_ham_user() is returning an error: Uncaught Error: Call to undefined function switch_to_blog().

The culprit of the issue is switch_to_blog() being called. This function is called only on WordPress Multisite installations, as the file responsible to make it available is only loaded when WordPress Multisite is active, it bails the spam/ham functions.

As there is no unit test for this function or its usage. So far I think the bug is from bbPress. Opening this ticket to get more feedback.

These are where I think the bugs are coming from:
https://bbpress.trac.wordpress.org/browser/trunk/src/includes/users/capabilities.php#L495
https://bbpress.trac.wordpress.org/browser/trunk/src/includes/users/capabilities.php#L573

Change History (3)

This ticket was mentioned in Slack in #bbpress by espellcaste. View the logs.


7 years ago

#2 @johnjamesjacoby
7 years ago

  • Keywords commit added
  • Milestone changed from Awaiting Review to 2.6
  • Owner set to johnjamesjacoby

This is an interesting and fun problem, actually.

These functions are hooked into their respective multisite-specific actions; they're never called directly.

But, there's no reason why functions like these shouldn't be first-class callables, and not just actions. I think it's fine to abstract the blog-switch logic out, since the chances of them always being loaded still seems slim.

I have a fix ready already.

#3 @johnjamesjacoby
7 years ago

  • Resolution set to fixed
  • Status changed from new to closed

In 6734:

Abstraction: abstract site switching functions to include an is_mulitsite() check.

This allows functions that are traditionally hook-only to be called directly, regardless of the installation type, and without littering the codebase with several is_multisite() switches.

Fixes #3179.

Note: See TracTickets for help on using tickets.