Skip to:
Content

bbPress.org

Opened 4 years ago

Closed 4 years ago

Last modified 4 years ago

#2804 closed defect (invalid)

Receiving “Notice” in back-end for set_current_user hook

Reported by: hellofromTonya Owned by: hellofromTonya
Milestone: Priority: low
Severity: minor Version:
Component: General Keywords:
Cc:

Description

Hey bbPress Gang,

I just wanted to report a minor issue of a Notice that is being thrown for the hook in actions.php on line 48:

add_action( 'set_current_user',         'bbp_setup_current_user',     10    );

I handled it in the core plugin like this:

add_action( 'plugins_loaded',       function() {
    remove_action( 'set_current_user',         'bbp_setup_current_user', 10 );
    add_action( 'wp_set_current_user',         'bbp_setup_current_user', 10 );
});

For your issues team, here is the notice:

Notice: bbp_setup_current_user was called <strong>incorrectly</strong>. The current user is being initialized without using $wp-&gt;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 /Users/tonya/Sites/sandbox/wp-includes/functions.php on line 3560

Looking at set_current_user, it was depreciated.

Simple fix:

add_action( 'wp_set_current_user',         'bbp_setup_current_user',     10    );

Attachments (1)

2804.1.diff (897 bytes) - added by hellofromTonya 4 years ago.

Download all attachments as: .zip

Change History (5)

#1 @hellofromTonya
4 years ago

  • Keywords has-patch added; needs-patch removed
  • Owner set to hellofromTonya

#2 follow-up: @thebrandonallen
4 years ago

Thanks for the patch @hellofromTonya, however it doesn't actually fix the issue, since the wp_set_current_user hook doesn't exist.

Are you using any plugins, themes, or code in your theme's functions.php that might be calling wp_set_current_user()?

#3 in reply to: ↑ 2 @hellofromTonya
4 years ago

  • Milestone Awaiting Review deleted
  • Resolution set to invalid
  • Status changed from new to closed

Replying to thebrandonallen:

Thanks for the patch @hellofromTonya, however it doesn't actually fix the issue, since the wp_set_current_user hook doesn't exist.

Are you using any plugins, themes, or code in your theme's functions.php that might be calling wp_set_current_user()?

You are correct about the patch.

Root Cause:
In the child theme, we are checking is_user_logged_in() which then follows the callback path to call bbp_setup_current_user. This call to is_user_logged_in(), one is unnecessary and (2) occurs off of genesis_init and not init or after_theme_setup; hence, we get the notice thrown.

bbPress is properly protecting itself from said issue.

Therefore, this ticket should be closed with no further action.

#4 @netweb
4 years ago

  • Keywords has-patch removed
  • Version 2.5.7 deleted

I think you'll find your issue is more a duplicate of #2412, details are in that ticket and information on the upstream ticket in WordPress.

If you have WP_DEBUG enabled and a theme or plugin is doing it wrong bbPress will call out this notice.

Note: See TracTickets for help on using tickets.