From 72fda0359f30d0f81a89e3ab369b1389b4cf2fb1 Mon Sep 17 00:00:00 2001 From: Pascal Birchler Date: Fri, 23 Jun 2023 16:03:25 +0000 Subject: [PATCH] I18N: Ensure `determine_locale()` does not potentially return an empty string. Call `get_locale()` as a last resort in case the sanitized locale is an empty string. Also swaps conditionals to cater for more typical use case and adds tests. Follow-up to [55862] Props Cybr, swissspidy. Fixes #58317. Built from https://develop.svn.wordpress.org/trunk@56003 git-svn-id: http://core.svn.wordpress.org/trunk@55515 1a063a9b-81f0-0310-95a4-ce76da25c4cd --- wp-includes/l10n.php | 10 ++++++---- wp-includes/version.php | 2 +- 2 files changed, 7 insertions(+), 5 deletions(-) diff --git a/wp-includes/l10n.php b/wp-includes/l10n.php index 8444bf2c82..951c1c316b 100644 --- a/wp-includes/l10n.php +++ b/wp-includes/l10n.php @@ -145,12 +145,14 @@ function determine_locale() { } else { $determined_locale = sanitize_locale_name( $_COOKIE['wp_lang'] ); } - } else if ( - ( isset( $_GET['_locale'] ) && 'user' === $_GET['_locale'] && wp_is_json_request() ) || - is_admin() + } elseif ( + is_admin() || + ( isset( $_GET['_locale'] ) && 'user' === $_GET['_locale'] && wp_is_json_request() ) ) { $determined_locale = get_user_locale(); - } else { + } + + if ( ! $determined_locale ) { $determined_locale = get_locale(); } diff --git a/wp-includes/version.php b/wp-includes/version.php index 0d805bb429..09f10ce4c6 100644 --- a/wp-includes/version.php +++ b/wp-includes/version.php @@ -16,7 +16,7 @@ * * @global string $wp_version */ -$wp_version = '6.3-alpha-56002'; +$wp_version = '6.3-alpha-56003'; /** * Holds the WordPress DB revision, increments when changes are made to the WordPress DB schema.