Changeset 65849
- Timestamp:
- 12/01/2026 01:21:01 PM (3 hours ago)
- Location:
- branches/7.2
- Files:
-
- 4 edited
-
. (modified) (1 prop)
-
src/wp-admin/includes/update.php (modified) (2 diffs)
-
src/wp-admin/update-core.php (modified) (2 diffs)
-
tests/phpunit/tests/admin/includesUpdate.php (modified) (2 diffs)
Legend:
- Unmodified
- Added
- Removed
-
branches/7.2
-
branches/7.2/src/wp-admin/includes/update.php
r65410 r65849 656 656 $plugin_update = get_site_transient( 'update_plugins' ); 657 657 658 /* 659 * Keys are added from the least to the most reliable, so a later key replaces an 660 * earlier one: main file names, then plugin files and directories, then the slugs 661 * from the plugin update data. Otherwise a plugin whose main file is named after 662 * another plugin's slug would show that plugin's name. 663 */ 664 foreach ( $all_plugins as $plugin_file => $plugin_data ) { 665 if ( isset( $plugin_data['Name'] ) ) { 666 $plugin_names[ basename( $plugin_file, '.php' ) ] = $plugin_data['Name']; 667 } 668 } 669 670 foreach ( $all_plugins as $plugin_file => $plugin_data ) { 671 $plugin_basename = dirname( $plugin_file ); 672 673 if ( isset( $plugin_data['Name'] ) ) { 674 $plugin_names[ $plugin_file ] = $plugin_data['Name']; 675 676 if ( '.' !== $plugin_basename ) { 677 $plugin_names[ $plugin_basename ] = $plugin_data['Name']; 678 } 679 } 680 } 681 658 682 if ( is_object( $plugin_update ) ) { 659 683 $plugin_updates = array(); … … 672 696 if ( ! empty( $plugin_data->slug ) && ! empty( $all_plugins[ $plugin_file ]['Name'] ) ) { 673 697 $plugin_names[ $plugin_data->slug ] = $all_plugins[ $plugin_file ]['Name']; 674 }675 }676 }677 678 foreach ( $all_plugins as $plugin_file => $plugin_data ) {679 $plugin_basename = dirname( $plugin_file );680 681 if ( isset( $plugin_data['Name'] ) ) {682 $plugin_names[ $plugin_file ] = $plugin_data['Name'];683 $plugin_names[ basename( $plugin_file, '.php' ) ] = $plugin_data['Name'];684 685 if ( '.' !== $plugin_basename ) {686 $plugin_names[ $plugin_basename ] = $plugin_data['Name'];687 698 } 688 699 } -
branches/7.2/src/wp-admin/update-core.php
r65226 r65849 1359 1359 1360 1360 // Requests without the form's update identifiers must not install all translations. 1361 $translation_update_ids = array_unique( 1362 array_map( 1363 'sanitize_text_field', 1364 wp_unslash( (array) ( $_POST['translations'] ?? array() ) ) 1365 ) 1366 ); 1367 $selected_translation_update_ids = array_unique( 1368 array_map( 1369 'sanitize_text_field', 1370 wp_unslash( (array) ( $_POST['checked'] ?? array() ) ) 1371 ) 1372 ); 1361 if ( isset( $_POST['translations'] ) ) { 1362 $translation_update_ids = array_unique( 1363 array_map( 1364 'sanitize_text_field', 1365 wp_unslash( (array) $_POST['translations'] ) 1366 ) 1367 ); 1368 $selected_translation_update_ids = array_unique( 1369 array_map( 1370 'sanitize_text_field', 1371 wp_unslash( (array) ( $_POST['checked'] ?? array() ) ) 1372 ) 1373 ); 1374 } elseif ( isset( $_GET['translations'] ) && is_string( $_GET['translations'] ) ) { 1375 /* 1376 * The filesystem credentials form posts back to the upgrader URL without the 1377 * fields of the Updates screen form, so the URL carries the selected updates. 1378 */ 1379 $translation_update_ids = array_unique( 1380 array_map( 1381 'sanitize_text_field', 1382 explode( ',', wp_unslash( $_GET['translations'] ) ) 1383 ) 1384 ); 1385 $selected_translation_update_ids = $translation_update_ids; 1386 } else { 1387 $translation_update_ids = array(); 1388 $selected_translation_update_ids = array(); 1389 } 1373 1390 1374 1391 $selected_translation_updates = wp_process_translation_update_selection( $translation_update_ids, $selected_translation_update_ids ); … … 1387 1404 require_once ABSPATH . 'wp-admin/includes/class-wp-upgrader.php'; 1388 1405 1389 $url = 'update-core.php?action=do-translation-upgrade ';1406 $url = 'update-core.php?action=do-translation-upgrade&translations=' . urlencode( implode( ',', array_keys( $selected_translation_updates ) ) ); 1390 1407 $nonce = 'upgrade-translations'; 1391 1408 $title = __( 'Update Translations' ); -
branches/7.2/tests/phpunit/tests/admin/includesUpdate.php
r65442 r65849 32 32 remove_all_filters( 'all_plugins' ); 33 33 remove_all_filters( 'pre_site_transient_update_plugins' ); 34 wp_cache_delete( 'plugins', 'plugins' ); 34 35 35 36 parent::tear_down(); … … 625 626 ); 626 627 } 628 629 /** 630 * Ensure that a plugin translation update is named after the plugin with that slug in 631 * the plugin update data, not after a plugin whose main file has the same name. 632 * 633 * @ticket 66663 634 */ 635 public function test_wp_get_translation_update_plugin_names_prefers_slugs_from_plugin_update_data() { 636 // get_plugins() reads installed plugins from this cache entry. 637 wp_cache_set( 638 'plugins', 639 array( 640 '' => array( 641 'bar/bar.php' => array( 642 'Name' => 'Bar', 643 ), 644 'zeta/bar.php' => array( 645 'Name' => 'Zeta', 646 ), 647 ), 648 ), 649 'plugins' 650 ); 651 652 set_site_transient( 653 'update_plugins', 654 (object) array( 655 'no_update' => array( 656 'bar/bar.php' => (object) array( 657 'slug' => 'bar', 658 ), 659 'zeta/bar.php' => (object) array( 660 'slug' => 'zeta', 661 ), 662 ), 663 ) 664 ); 665 666 $plugin_names = wp_get_translation_update_plugin_names(); 667 668 $this->assertSame( 'Bar', $plugin_names['bar'], 'The slug from the plugin update data should name the plugin that has it.' ); 669 $this->assertSame( 'Zeta', $plugin_names['zeta'], 'The other plugin should keep its own slug.' ); 670 } 671 672 /** 673 * Ensure that a plugin directory name takes precedence over another plugin's main file name. 674 * 675 * @ticket 66663 676 */ 677 public function test_wp_get_translation_update_plugin_names_prefers_directories_over_main_file_names() { 678 // get_plugins() reads installed plugins from this cache entry. 679 wp_cache_set( 680 'plugins', 681 array( 682 '' => array( 683 'bar/plugin.php' => array( 684 'Name' => 'Bar', 685 ), 686 'zeta/bar.php' => array( 687 'Name' => 'Zeta', 688 ), 689 ), 690 ), 691 'plugins' 692 ); 693 694 $this->assertSame( 695 'Bar', 696 wp_get_translation_update_name( 697 (object) array( 698 'type' => 'plugin', 699 'slug' => 'bar', 700 ) 701 ), 702 'The plugin in the bar directory should name the update for the bar slug.' 703 ); 704 } 705 706 /** 707 * Ensure that processing the selection again with only the selected updates, as the 708 * Updates screen does after asking for filesystem credentials, keeps the deferrals 709 * made by the first request. 710 * 711 * @ticket 66663 712 */ 713 public function test_wp_process_translation_update_selection_after_filesystem_credentials_keeps_deferrals() { 714 $updates = array(); 715 716 foreach ( array( 'first-plugin', 'second-plugin' ) as $slug ) { 717 $updates[ $slug ] = (object) array( 718 'type' => 'plugin', 719 'slug' => $slug, 720 'language' => 'de_DE', 721 'version' => '1.0.0', 722 ); 723 } 724 725 set_site_transient( 726 'update_plugins', 727 (object) array( 728 'translations' => array_map( 'get_object_vars', array_values( $updates ) ), 729 ) 730 ); 731 732 $first_id = wp_get_translation_update_id( $updates['first-plugin'] ); 733 $second_id = wp_get_translation_update_id( $updates['second-plugin'] ); 734 735 // The Updates screen form, with only the first update selected. 736 $selected = wp_process_translation_update_selection( array( $first_id, $second_id ), array( $first_id ) ); 737 738 $this->assertSame( array( $first_id ), array_keys( $selected ), 'The first request should select the checked update.' ); 739 740 // The filesystem credentials form posts back only the selected updates. 741 $selected = wp_process_translation_update_selection( array( $first_id ), array( $first_id ) ); 742 743 $this->assertSame( array( $first_id ), array_keys( $selected ), 'The request after the credentials form should select the same update.' ); 744 $this->assertSame( array( $second_id ), array_keys( wp_get_deferred_translation_updates() ), 'The update deferred by the first request should stay deferred.' ); 745 } 627 746 }
Note:
See TracChangeset
for help on using the changeset viewer.