[buddypress-trac] [BuddyPress Trac] #6589: bp_setup_current_user() over zealous checking for did_action( "after_setup_theme" )
buddypress-trac
noreply at wordpress.org
Thu Aug 13 10:13:27 UTC 2015
#6589: bp_setup_current_user() over zealous checking for did_action(
"after_setup_theme" )
------------------------------+-------------------------------------
Reporter: bobbingwide | Owner:
Type: defect (bug) | Status: new
Priority: high | Milestone: Awaiting Review
Component: Component - Core | Version: 2.3.2
Severity: minor | Keywords: needs-patch 2nd-opinion
------------------------------+-------------------------------------
With WordPress-SEO, BuddyPress and WP_DEBUG true, BuddyPress produces the
following _doing_it_wrong message in the Dashboard.
`The current user is being initialized without using $wp->init().`
In my opinion this message can be avoided by changing the test to
something more closely aligned to the problem it is try to warn against...
the fact that the current user may not be set.
With the current version of WordPress, 4.2 and above, the test can be
changed to
{{{
global $current_user;
if ( is_null( $current_user ) ) {
_doing_it_wrong( ... );
}
}}}
See http://wordpress.stackexchange.com/questions/198185/what-is-valid-
timing-of-using-current-user-can-and-related-functions.
bbPress has the same problem.
An alternative approach, that I did not investigate, is to not register
the action hook for bp_set_current_user until 'after_setup_theme' has been
fired.
--
Ticket URL: <https://buddypress.trac.wordpress.org/ticket/6589>
BuddyPress Trac <http://buddypress.org/>
BuddyPress Trac
More information about the buddypress-trac
mailing list