From b713c5eb9cdcb081faa301ce9983d7ea23481194 Mon Sep 17 00:00:00 2001 From: Pascal Birchler Date: Mon, 15 Jan 2024 18:57:14 +0000 Subject: [PATCH] Upgrade/Install: Fix JavaScript localization on install page. Blocks registration causes scripts to be initialized and localized very early, before the current locale has been properly set on the installation page. This changes `determine_locale()` so that the locale chosen during installation is recognized and loaded earlier, ensuring proper script localization. Props sabernhardt, NekoJonez, jornp, costdev. Fixes #58696 Built from https://develop.svn.wordpress.org/trunk@57286 git-svn-id: http://core.svn.wordpress.org/trunk@56792 1a063a9b-81f0-0310-95a4-ce76da25c4cd --- wp-admin/install.php | 2 +- wp-includes/l10n.php | 9 +++++++++ wp-includes/version.php | 2 +- 3 files changed, 11 insertions(+), 2 deletions(-) diff --git a/wp-admin/install.php b/wp-admin/install.php index bf102893ff..34d5d4c7f7 100644 --- a/wp-admin/install.php +++ b/wp-admin/install.php @@ -329,7 +329,7 @@ if ( defined( 'DO_NOT_UPGRADE_GLOBAL_TABLES' ) ) { */ $language = ''; if ( ! empty( $_REQUEST['language'] ) ) { - $language = preg_replace( '/[^a-zA-Z0-9_]/', '', $_REQUEST['language'] ); + $language = sanitize_locale_name( $_REQUEST['language'] ); } elseif ( isset( $GLOBALS['wp_local_package'] ) ) { $language = $GLOBALS['wp_local_package']; } diff --git a/wp-includes/l10n.php b/wp-includes/l10n.php index 67bfb1a26e..598a485468 100644 --- a/wp-includes/l10n.php +++ b/wp-includes/l10n.php @@ -150,6 +150,15 @@ function determine_locale() { ( isset( $_GET['_locale'] ) && 'user' === $_GET['_locale'] && wp_is_json_request() ) ) { $determined_locale = get_user_locale(); + } elseif ( + ( ! empty( $_REQUEST['language'] ) || isset( $GLOBALS['wp_local_package'] ) ) + && wp_installing() + ) { + if ( ! empty( $_REQUEST['language'] ) ) { + $determined_locale = sanitize_locale_name( $_REQUEST['language'] ); + } else { + $determined_locale = $GLOBALS['wp_local_package']; + } } if ( ! $determined_locale ) { diff --git a/wp-includes/version.php b/wp-includes/version.php index 2163dbf807..15b18f035a 100644 --- a/wp-includes/version.php +++ b/wp-includes/version.php @@ -16,7 +16,7 @@ * * @global string $wp_version */ -$wp_version = '6.5-alpha-57285'; +$wp_version = '6.5-alpha-57286'; /** * Holds the WordPress DB revision, increments when changes are made to the WordPress DB schema.