#3179 closed defect (bug) (fixed)
bbp_make_*_user() outputs error on non-multisite installations
Reported by: | espellcaste | Owned by: | 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
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.