#2309 closed defect (bug) (fixed)
WordPress theme previews triggering bbp_setup_current_user() debug notice
Reported by: | michelwppi | Owned by: | johnjamesjacoby |
---|---|---|---|
Milestone: | 2.6 | Priority: | normal |
Severity: | major | Version: | 2.3 |
Component: | API - Roles/Capabilities | Keywords: | |
Cc: | team@…, Chouby, leho@… |
Description
During tests with WP 3.5.1 and WP 3.6beta, we have this annoying notice...
Notice: bbp_setup_current_user was called incorrectly. The current user is being initialized without using $wp->init(). Please see Debugging in WordPress for more information. (This message was added in version 2.3.) in /Applications/MAMP/htdocs/wp_svn36/wp-includes/functions.php on line 2986
Why this message ?
Only bbPress 2.3 call this function (no other plugins) !
How to avoid only it when debugging (WP_DEBUG true) ?
Thanks
Michel
Change History (35)
#2
@
11 years ago
- Milestone Awaiting Review deleted
- Resolution set to invalid
- Status changed from new to closed
This is more of a support question than a bug. This warning is here intentionally, to alert you to some piece of code that's working incorrectly.
Closing as invalid, as the warning is doing exactly what's intended to do.
#3
@
11 years ago
- Cc team@… removed
I remain a little perplexed about this Notice limitation (inside filter action after_setup_theme line 146 of sub-actions.php) imposed by bbPress 2.3 when you need to get user's ID ( get_current_user_id ) or user's meta (not linked with bbPress) from current user (get_user_option).
Please find solution extracted from a class of a plugin setting live dashboard language (backside).
Updated 2013-04-24 after a week tests:
First "brutal" workaround was based on removing filter: see commented lines below
Second approach was based on add of a filter action after_setup_theme to get user meta (here user_locale) - this approach is not possible here in the function called by locale filter - purpose: changing live the dashboard language UI
// 2.8.0 dashboard language add_filter( 'locale', array( &$this, 'admin_side_locale') ); add_action( 'after_setup_theme', array( &$this, 'admin_user_id_locale') ); // 2.8.8 /** * Admin side localization - user's dashboard from locale filter * * @since 2.8.0 * */ function admin_side_locale( $locale = 'en_US' ) { // to avoid notice with bbPress 2.3 - brutal approach if ( class_exists( 'bbPress') ) remove_action( 'set_current_user', 'bbp_setup_current_user' ); $locale = get_user_option( 'user_locale' ); if ( class_exists( 'bbPress') ) add_action( 'set_current_user', 'bbp_setup_current_user', 10 ); // cannot be replaced here by (no operant in this filter // $locale = $this->user_locale; // see after_setup_theme filter below if ( empty( $locale ) ) $locale = $this->get_default_locale(); return $locale; } * from after_setup_theme action - tested but not used after tests * * @since 2.8.8 * */ function admin_user_id_locale () { $this->user_locale = get_user_option( 'user_locale' ); }
These solutions will be published in xili-language v 2.8.8 when used with bbPress 2.3 in multilingual context.
Hope that help another dev. or cause another comments,
M.
#4
@
11 years ago
- Component changed from General to Roles/Capabilities
- Keywords customize added
- Milestone set to Awaiting Review
- Resolution invalid deleted
- Severity changed from normal to major
- Status changed from closed to reopened
Hi,
I reopen the ticket because this notice appear in Customize theme double screen :
Tested in WP 3.6 beta, without any plugin, only bbPress 2.3 plugin and twentytwelve theme or twentythirteen :
The notice appears on the top of the right frame (where home page is displayed).
It seems to confirm that the notice 'limitation' is too restrictive
Hope that help...
M.
#6
@
11 years ago
- Cc team@… added
I open this ticket in core WordPress track :
http://core.trac.wordpress.org/ticket/24141
(note : the link in your comment is not right)
#7
@
11 years ago
- Keywords customize removed
- Milestone Awaiting Review deleted
- Resolution set to invalid
- Status changed from reopened to closed
Closing in lieu of #WP24169.
#8
@
11 years ago
- Summary changed from Notice: bbp_setup_current_user was called incorrectly. The current user is being initialized without using $wp->init(). Please see Debugging in WordPress for more information. (This message was added in version 2.3.) in [...]wp_svn36/wp-includes/functions.php on line 2986 to WordPress theme previews triggering bbp_setup_current_user() debug notice
#10
@
11 years ago
- Cc Chouby added
- Resolution invalid deleted
- Status changed from closed to reopened
As @nacin mentionned in #WP24169, I believe that this ticket rises a larger issue than the WP customizer. It rises a conflict with most multilingual plugins which permit each user to define their own language (I am aware of at least Xili Language, WP native Dashboard, Polylang but there are probably more), which can hook to the 'locale' filter called by get_locale() *after* roles have been defined.
If that's doing it wrong, then I really don't understand why and so far only bbpress is warning us against this practice.
Again, I may have understood nothing but if that's creates issues for bbpress, I wonder why 'bbp_setup_current_user' is not hooked to 'after_setup_theme' instead of 'set_current_user'. Is it realistic to do so?
#11
@
11 years ago
Again, I full agree with Chouby, bbPress don't follow the timeline of wp-settings... In the near past, I have try to write an article about this timeline of actions during start of WP :
Hope that help to find an elegant solution especially for online test of theme...
M.
#12
follow-up:
↓ 13
@
10 years ago
I've been trying to resolve an issue that I traced down to being related to this one. It exhibited itself in debug_log like this:
Notice: bbp_setup_current_user was called incorrectly. The current user is being initialized without using $wp->init(). Please see Debugging in WordPress for more information. (This message was added in version 2.3.)
Through some stack tracing and variable duping, I tracked the issue down to the WooDojo plugin. This plugin in particular loads bundles of custom widgets and they don't seem to protect against the infamous "after_setup_theme" state before trying to access the current user. So it exhibits itself as a BBPress plugin issue when in fact WooDojo is making the mistake of making sure the theme is setup before trying to mess with the current user. At any rate, it was a simple fix in line 122 of the ./plugins/woodojo/classes/base.class.php file from this:
add_action( 'plugins_loaded', array( &$this, 'init_component_loaders' ) );
to this:
add_action( 'after_setup_theme', array( &$this, 'init_component_loaders' ) );
I'm somewhat of a nooB, so take this with a grain of salt... just hope it helps save someone some time.
#13
in reply to:
↑ 12
@
10 years ago
I don't have WooDojo Plugin but have been getting the notice.
Notice: bbp_setup_current_user was called incorrectly. The current user is being initialized without using $wp->init().
Replying to grundyoso:
Through some stack tracing and variable duping, I tracked the issue down to the WooDojo plugin.
#14
@
10 years ago
@OpenCode This is not a bbPress issue, you will find it will be a plugin or theme conflict doing it wrong, disable each of your plugins one by one until the notice is gone, you'll then know the conflicting plugin, if not a plugin then switch to a WordPress default theme, e.g. Twenty Fourteen.
This ticket is also on a closed milestone and Trac is not for support.
If you have any further questions (or anyone else for that matter) please post on the support forums:
#15
@
10 years ago
- Milestone set to 2.6
- Owner set to johnjamesjacoby
- Status changed from reopened to new
Let's fix this (for now) so it doesn't cause anymore support burden.
#17
@
9 years ago
Notice: bbp_setup_current_user was called incorrectly. The current user is being initialized without using $wp->init(). Please see Debugging in WordPress for more information. (This message was added in version 2.3.) in /is/htdocs/wp10591786_F7AET0I6TB/www/mysite/wp-includes/functions.php on line 3547
Was the patch already released? For me it is still an issue. (Wordpress 4.1.2, bbPress 2.5.7)
#18
@
9 years ago
Sorry to bring this up again (and I'm not sure if this should be in a new ticket), but JetPack's stats module seems to trigger this warning too - it looks like simply having JetPack installed and activated is enough to cause this error to happen.
The code (eventually) calls current_user_can
from plugins_loaded
(see https://plugins.trac.wordpress.org/browser/jetpack/tags/3.5.3/modules/stats.php#L69)
Relevant contents of debug log:
Notice: bbp_setup_current_user was called <strong>incorrectly</strong>. The current user is being initialized without using $wp->init(). Please see <a href="https://codex.wordpress.org/Debugging_in_WordPress">Debugging in WordPress</a> for more information. (This message was added in version 2.3.) in /var/www/wp-includes/functions.php on line 3560 Stack trace: 1. {main}() /var/www/index.php:0 2. require() /var/www/index.php:17 3. require_once() /var/www/wp-blog-header.php:12 4. require_once() /var/www/wp-load.php:37 5. require_once() /var/www/wp-config.php:187 6. do_action() /var/www/wp-settings.php:237 7. call_user_func_array:{/var/www/wp-includes/plugin.php:496}() /var/www/wp-includes/plugin.php:496 8. Jetpack::load_modules() /var/www/wp-includes/plugin.php:496 9. do_action() /var/www/wp-content/plugins/jetpack/class.jetpack.php:1146 10. call_user_func_array:{/var/www/wp-includes/plugin.php:496}() /var/www/wp-includes/plugin.php:496 11. stats_load() /var/www/wp-includes/plugin.php:496 12. current_user_can() /var/www/wp-content/plugins/jetpack/modules/stats.php:69 13. wp_get_current_user() /var/www/wp-includes/capabilities.php:1385 14. get_currentuserinfo() /var/www/wp-includes/pluggable.php:58 15. wp_set_current_user() /var/www/wp-includes/pluggable.php:119 16. do_action() /var/www/wp-includes/pluggable.php:41 17. call_user_func_array:{/var/www/wp-includes/plugin.php:496}() /var/www/wp-includes/plugin.php:496 18. bbp_setup_current_user() /var/www/wp-includes/plugin.php:496 19. _doing_it_wrong() /var/www/wp-content/plugins/bbpress/includes/core/sub-actions.php:147 20. trigger_error() /var/www/wp-includes/functions.php:3560
#19
@
9 years ago
Okay, so 9. looks like the do_action( 'jetpack_modules_loaded' );
which is indeed meant to fire stats_load()
which is here:
and ... okay, drat, yeah, that was probably my fault. I didn't realize it was before init when that fired -- too many steps deep.
We'll have a fix up shortly.
Thanks for the catch, @x2764tech
#20
@
9 years ago
Fix for Jetpack: https://github.com/Automattic/jetpack/commit/76537541cefa867d09ca0e38c8b4509e868ca81b
I'm flagging it to merge into our next point release, but we don't really have one scheduled -- just know that it will go out with the next point release.
#23
@
9 years ago
- Resolution fixed deleted
- Status changed from closed to reopened
Notice: bbp_setup_current_user was called incorrectly. The current user is being initialized without using $wp->init(). Please see Debugging in WordPress for more information.
Getting an issue when customizing the theme: Zerife Lite > http://themeisle.com/themes/zerif-lite/
Any solutions?
#24
@
9 years ago
- Resolution set to fixed
- Status changed from reopened to closed
@workcafe, it is an issue with the theme, not bbPress, you should contact the theme authors or post on their support forums etc.
Anyone else who arrives here in the future please do no not reopen the ticket, comments are not closed and you are free to add a comment but there is no need to reopen the ticket :)
#25
follow-up:
↓ 27
@
9 years ago
Just wanted to comment here. I get this error even with twentyfifteen as a theme and only bbPress active in terms of plugins. It actually occurs regardless of the theme when bbPress is active. I am using 4.3.1 with VVV
#27
in reply to:
↑ 25
@
9 years ago
Replying to mantismamita:
Just wanted to comment here. I get this error even with twentyfifteen as a theme and only bbPress active in terms of plugins. It actually occurs regardless of the theme when bbPress is active. I am using 4.3.1 with VVV
@mantismamita I cannot replicate this on my VVV install with ONLY bbPress 2.5.8 activated and using the Twenty Fifteen theme, if you have any other plugins active deactivate those and remove any mu-plugins
if you are using them.
#28
@
9 years ago
@netweb I confirm NO other plugins active (including mu). Very few other plugins were ever active on this install (BuddyPress 2.4.0 and bbPress Genesis Extend 1.1.1) The same error is present regardless of theme, tested with P2 and Genesis Framework. Just to be clear it is only visible when the Customiser is in use.
This ticket was mentioned in Slack in #bbpress by casiepa. View the logs.
9 years ago
#30
@
9 years ago
- Resolution fixed deleted
- Status changed from closed to reopened
bbp_setup_current_user was called incorrectly. The current user is being initialized without using $wp->init()
Error in Wordpress 4.4.1 with bbPress 2.5.8-5815 and no other plugin installed.
Seems to have been going on for a few years so how is it that you disable the message as its really annoying when trying to debug other things?
#31
@
9 years ago
- Resolution set to fixed
- Status changed from reopened to closed
bbPress is not broken.
bbPress is telling you that something else is broken.
WordPress's Customizer is special cased to be broken on purpose.
The Jetpack plugin also was recently broken, and promptly fixed.
If you see this notice in your debug logs, bbPress is kindly letting you know that something other than bbPress is breaking bbPress.
bbPress is not broken.
More details :
bbp_setup_current_user was called/fired by function get_user_option() from another plugin via locale filter...
Doing tests, before calling get_user_option it is verified that user is logged but the notice occurred !!
Are you sure that the condition if ( ! did_action( 'after_setup_theme' ) ) { - is not too much restrictive to fire this notice ?
Can you provide more explanation ?
M.