Commit 6ae93b46ee for wordpress.org

commit 6ae93b46ee0542bb207b2f1dbb91298e2ae32083
Author: audrasjb <audrasjb@git.wordpress.org>
Date:   Tue Dec 1 12:29:54 2026 +0000

    Upgrade/Install: Keep the translation update selection after asking for credentials.

    When WordPress needs FTP or SSH credentials, the "Connection Information" form posts back to `update-core.php?action=do-translation-upgrade` without `translations[]` and `checked[]`. Since [65226], `wp_process_translation_update_selection()` returns `false` for that request and the Updates screen reloads, so the selected translations were never installed.

    This changeset:
    - Carries the selected update IDs in the upgrader URL (`&translations=<id>,<id>`), the same way plugin and theme updates do. The request after the credentials form reads them from there. Deferrals made by the first request are kept.
    - Builds the plugin names in `wp_get_translation_update_plugin_names()` from the least to the most reliable key: main file names, then plugin files and directories, then slugs from the plugin update data. Before, a plugin whose main file was named after another plugin's slug showed that plugin's name.

    Developed in https://github.com/WordPress/wordpress-develop/pull/15909.

    Follow-up to [65226].

    Props aryanjasala, audrasjb, mayankmajeji.
    Fixes #66663.
    See #42281.


    Built from https://develop.svn.wordpress.org/trunk@65844


    git-svn-id: http://core.svn.wordpress.org/trunk@64873 1a063a9b-81f0-0310-95a4-ce76da25c4cd

diff --git a/wp-admin/includes/update.php b/wp-admin/includes/update.php
index 60d84a54da..0e2f1da4e1 100644
--- a/wp-admin/includes/update.php
+++ b/wp-admin/includes/update.php
@@ -658,6 +658,30 @@ function wp_get_translation_update_plugin_names() {
 	$all_plugins   = get_plugins();
 	$plugin_update = get_site_transient( 'update_plugins' );

+	/*
+	 * Keys are added from the least to the most reliable, so a later key replaces an
+	 * earlier one: main file names, then plugin files and directories, then the slugs
+	 * from the plugin update data. Otherwise a plugin whose main file is named after
+	 * another plugin's slug would show that plugin's name.
+	 */
+	foreach ( $all_plugins as $plugin_file => $plugin_data ) {
+		if ( isset( $plugin_data['Name'] ) ) {
+			$plugin_names[ basename( $plugin_file, '.php' ) ] = $plugin_data['Name'];
+		}
+	}
+
+	foreach ( $all_plugins as $plugin_file => $plugin_data ) {
+		$plugin_basename = dirname( $plugin_file );
+
+		if ( isset( $plugin_data['Name'] ) ) {
+			$plugin_names[ $plugin_file ] = $plugin_data['Name'];
+
+			if ( '.' !== $plugin_basename ) {
+				$plugin_names[ $plugin_basename ] = $plugin_data['Name'];
+			}
+		}
+	}
+
 	if ( is_object( $plugin_update ) ) {
 		$plugin_updates = array();

@@ -678,19 +702,6 @@ function wp_get_translation_update_plugin_names() {
 		}
 	}

-	foreach ( $all_plugins as $plugin_file => $plugin_data ) {
-		$plugin_basename = dirname( $plugin_file );
-
-		if ( isset( $plugin_data['Name'] ) ) {
-			$plugin_names[ $plugin_file ]                     = $plugin_data['Name'];
-			$plugin_names[ basename( $plugin_file, '.php' ) ] = $plugin_data['Name'];
-
-			if ( '.' !== $plugin_basename ) {
-				$plugin_names[ $plugin_basename ] = $plugin_data['Name'];
-			}
-		}
-	}
-
 	return $plugin_names;
 }

diff --git a/wp-admin/update-core.php b/wp-admin/update-core.php
index 90e4d4aa60..8e3946dfe5 100644
--- a/wp-admin/update-core.php
+++ b/wp-admin/update-core.php
@@ -1358,18 +1358,35 @@ if ( 'upgrade-core' === $action ) {
 	check_admin_referer( 'upgrade-translations' );

 	// Requests without the form's update identifiers must not install all translations.
-	$translation_update_ids          = array_unique(
-		array_map(
-			'sanitize_text_field',
-			wp_unslash( (array) ( $_POST['translations'] ?? array() ) )
-		)
-	);
-	$selected_translation_update_ids = array_unique(
-		array_map(
-			'sanitize_text_field',
-			wp_unslash( (array) ( $_POST['checked'] ?? array() ) )
-		)
-	);
+	if ( isset( $_POST['translations'] ) ) {
+		$translation_update_ids          = array_unique(
+			array_map(
+				'sanitize_text_field',
+				wp_unslash( (array) $_POST['translations'] )
+			)
+		);
+		$selected_translation_update_ids = array_unique(
+			array_map(
+				'sanitize_text_field',
+				wp_unslash( (array) ( $_POST['checked'] ?? array() ) )
+			)
+		);
+	} elseif ( isset( $_GET['translations'] ) && is_string( $_GET['translations'] ) ) {
+		/*
+		 * The filesystem credentials form posts back to the upgrader URL without the
+		 * fields of the Updates screen form, so the URL carries the selected updates.
+		 */
+		$translation_update_ids          = array_unique(
+			array_map(
+				'sanitize_text_field',
+				explode( ',', wp_unslash( $_GET['translations'] ) )
+			)
+		);
+		$selected_translation_update_ids = $translation_update_ids;
+	} else {
+		$translation_update_ids          = array();
+		$selected_translation_update_ids = array();
+	}

 	$selected_translation_updates = wp_process_translation_update_selection( $translation_update_ids, $selected_translation_update_ids );

@@ -1386,7 +1403,7 @@ if ( 'upgrade-core' === $action ) {
 	require_once ABSPATH . 'wp-admin/admin-header.php';
 	require_once ABSPATH . 'wp-admin/includes/class-wp-upgrader.php';

-	$url     = 'update-core.php?action=do-translation-upgrade';
+	$url     = 'update-core.php?action=do-translation-upgrade&translations=' . urlencode( implode( ',', array_keys( $selected_translation_updates ) ) );
 	$nonce   = 'upgrade-translations';
 	$title   = __( 'Update Translations' );
 	$context = WP_LANG_DIR;
diff --git a/wp-includes/version.php b/wp-includes/version.php
index 58e7870dc6..414aa800fb 100644
--- a/wp-includes/version.php
+++ b/wp-includes/version.php
@@ -16,7 +16,7 @@
  *
  * @global string $wp_version
  */
-$wp_version = '7.3-alpha-65840';
+$wp_version = '7.3-alpha-65844';

 /**
  * Holds the WordPress DB revision, increments when changes are made to the WordPress DB schema.