[wp-trac] [WordPress Trac] #51947: When Customizer `setup_theme` action fails during wp-settings.php, WordPress crashes due to missing global $wp_locale
WordPress Trac
noreply at wordpress.org
Sun Dec 6 12:48:49 UTC 2020
#51947: When Customizer `setup_theme` action fails during wp-settings.php,
WordPress crashes due to missing global $wp_locale
--------------------------+-----------------------------
Reporter: Guss77 | Owner: (none)
Type: defect (bug) | Status: new
Priority: normal | Milestone: Awaiting Review
Component: Customize | Version: 5.5.3
Severity: major | Keywords:
Focuses: |
--------------------------+-----------------------------
The `wp-settings.php` sets up the global `$wp_locale` (line 499 in
WordPress 5.5.3) but before doing that it calls `do_action( 'setup_theme'
);` (line 478).
The problem is that `WP_Customize_Manager::setup_theme()` has several
failure actions that call the class's `wp_die()` "wrapper" which -
depending on the value of the `messenger_channel` might try to call
`wp_enqueue_scripts()`, which will eventually call
`wp_localize_jquery_ui_datepicker()` that expects `$wp_locale` to be
already set. The result is a crash.
Here is one such stack trace:
{{{
PHP Fatal error: Uncaught Error: Call to a member function is_rtl() on
null in /var/www/html/wp-includes/script-loader.php:1684
Stack trace:
#0 /var/www/html/wp-includes/class-wp-hook.php(287):
wp_localize_jquery_ui_datepicker('')
#1 /var/www/html/wp-includes/class-wp-hook.php(311):
WP_Hook->apply_filters(NULL, Array)
#2 /var/www/html/wp-includes/plugin.php(478): WP_Hook->do_action(Array)
#3 /var/www/html/wp-includes/script-loader.php(2001):
do_action('wp_enqueue_scri...')
#4 /var/www/html/wp-includes/class-wp-customize-manager.php(454):
wp_enqueue_scripts()
#5 /var/www/html/wp-includes/class-wp-customize-manager.php(551):
WP_Customize_Manager->wp_die(0, 'Non-existent ch...')
#6 /var/www/html/wp-includes/class-wp-hook.php(287):
WP_Customize_Manager->setup_theme('')
#7 /var/www/html/wp-includes/class-wp-hook.php(311):
WP_Hook->apply_filters(NULL, Array)
#8 /var/www/html/wp-includes/plugin.php(478): WP_Hook->do_action(Array)
#9 /var/www/html/wp-settings.php(478): do_action('setup_theme')
#10 /var/www/html/wp-config.php(97): req...
in /var/www/html/wp-includes/script-loader.php on line 1684, referer:
https://somesite.com/
}}}
Moving the `do_action( 'setup_theme' );` line down a few lines until after
the local has been setup, and just before loading the active theme's
`function.php` file (which is arguably where it was supposed to be in the
first place) solves the problem.
--
Ticket URL: <https://core.trac.wordpress.org/ticket/51947>
WordPress Trac <https://core.trac.wordpress.org/>
WordPress publishing platform
More information about the wp-trac
mailing list