Make WordPress Core

Opened 7 years ago

Closed 7 years ago

Last modified 7 years ago

#38535 closed defect (bug) (fixed)

Don't init WP_Locale_Switcher in wp_load_translations_early()

Reported by: ocean90's profile ocean90 Owned by: ocean90's profile ocean90
Milestone: 4.7 Priority: high
Severity: normal Version: 4.7
Component: I18N Keywords: has-patch
Focuses: Cc:


See ticket:29783:59.

WP_Locale_Switcher uses get_locale()/get_user_locale() to set the original locale. Both functions can return a fatal error if WordPress isn't fully initialized. [38976] tries to fix this but in a bad way. wp_load_translations_early() sets the locale based on various factors like WPLANG or $wp_local_package. [38976] assumes that it's always en_US.

I'm not aware of a use case where someone would need to switch locales while the site is crashing. I'm proposing to revert [38976] and [38977] and to remove WP_Locale_Switcher from wp_load_translations_early().

Related: #30049

Attachments (1)

38535.patch (941 bytes) - added by ocean90 7 years ago.

Download all attachments as: .zip

Change History (4)

7 years ago

This ticket was mentioned in Slack in #core by ocean90. View the logs.

7 years ago

#2 @ocean90
7 years ago

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

In 39005:

I18N: Don't initialize WP_Locale_Switcher in wp_load_translations_early().

wp_load_translations_early() is used when WordPress isn't fully initialized. Therefore using the WP_Locale_Switcher with get_locale()/get_user_locale() can cause PHP fatal errors.
This reverts [38976] and [38977], and instead removes WP_Locale_Switcher from wp_load_translations_early().

See #29783.
Fixes #38535.

#3 @ocean90
7 years ago

In 39130:

Load: Remove unused global imports in wp_load_translations_early().

See #38535.

Note: See TracTickets for help on using tickets.