Skip to:
Content

BuddyPress.org

Opened 8 years ago

Closed 8 years ago

Last modified 8 years ago

#7305 closed defect (bug) (fixed)

get_user_locale() always loads current user before init

Reported by: johnjamesjacoby's profile johnjamesjacoby Owned by: djpaul's profile djpaul
Milestone: 2.7.1 Priority: high
Severity: major Version: 2.7
Component: Core Keywords: needs-patch needs-testing
Cc: stephen@…, gary@…, slaFFik, leho@…

Description

In WordPress 4.7, the get_user_locale() function will always invoke the current user object before the init hook has fired.

This results in the very common The current user is being initialized without using $wp->init() notice on every page load.

Looks like it's time to retire this notice for good, and patch the unintended consequences of this reorder.

Attachments (1)

7305.patch (1.2 KB) - added by johnjamesjacoby 8 years ago.
Remove current_user notice code & warning for WordPress 4.7 support

Download all attachments as: .zip

Change History (14)

#2 follow-up: @DJPaul
8 years ago

Can we do something smart like not sending a notice for the get_user_locale() instance -- perhaps via backtrace detection -- and keep the rest in place?

Or, only throw the notice if it's coming from a BuddyPress plugin file.

#4 in reply to: ↑ 2 @johnjamesjacoby
8 years ago

Replying to DJPaul:

Can we do something smart like not sending a notice for the get_user_locale() instance -- perhaps via backtrace detection -- and keep the rest in place?

I don't think so, because this is just the way WordPress is going to work now. It may actually be for the better, since BuddyPress originally was a big offender of this back-in-the-day (when we would load the current user early and send them to purgatory of they were a spammer.)

Replying to ocean90:

Would https://core.trac.wordpress.org/ticket/23016#comment:16 help BuddyPress too?

I think so, yes, but it needs testing to confirm. BuddyPress doesn't use primitive roles yet, but it has used mapped capabilities for a long while, and we've wanted to have primitive roles for a long while.

Version 1, edited 8 years ago by johnjamesjacoby (previous) (next) (diff)

#5 @johnjamesjacoby
8 years ago

In #WP23016, the wp_roles_init action is what BuddyPress & bbPress would use going forward, so in that case, yes.

I still want to work that out over there, and confirm that it works as intended for bbPress's JIT roles setup.

@johnjamesjacoby
8 years ago

Remove current_user notice code & warning for WordPress 4.7 support

#6 @netweb
8 years ago

  • Cc stephen@… added

#7 @pento
8 years ago

  • Cc gary@… added

#8 @DJPaul
8 years ago

  • Milestone changed from Awaiting Review to 2.7.1

As always, if someone patches something in the Awaiting Review milestone, *please* move it out to somewhere more appropriate. Patches get missed here.

#9 @slaFFik
8 years ago

  • Cc slaFFik added

This ticket was mentioned in Slack in #buddypress by boone. View the logs.


8 years ago

#11 @djpaul
8 years ago

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

In 11222:

Core: remove wp->init() PHP notice from bp_setup_current_user() due to load order changes in WordPress 4.7.

In WordPress 4.7, the get_user_locale() function will always invoke the current user object before the init hook has fired.
This should cause no other regression for BuddyPress as we don't use primitive roles yet.

Fixes #7305, props johnjamesjacoby

#12 @djpaul
8 years ago

In 11223:

Core: remove wp->init() PHP notice from bp_setup_current_user() due to load order changes in WordPress 4.7.

In WordPress 4.7, the get_user_locale() function will always invoke the current user object before the init hook has fired.
This should cause no other regression for BuddyPress as we don't use primitive roles yet.

Fixes #7305 for the 2.7 branch, props johnjamesjacoby

#13 @lkraav
8 years ago

  • Cc leho@… added
Note: See TracTickets for help on using tickets.