Ticket #51928: 51928.4.diff
File 51928.4.diff, 4.0 KB (added by , 4 years ago) |
---|
-
wp-admin/includes/class-wp-upgrader.php
diff --git a/wp-admin/includes/class-wp-upgrader.php b/wp-admin/includes/class-wp-upgrader.php index 5faac56213..5e85f18006 100644
a b class WP_Upgrader { 666 666 * or false if unable to connect to the filesystem. 667 667 */ 668 668 public function run( $options ) { 669 $start_time = time(); 669 670 670 671 $defaults = array( 671 672 'package' => '', // Please always pass this. … … class WP_Upgrader { 728 729 $this->skin->before(); 729 730 730 731 if ( is_wp_error( $res ) ) { 732 $this->send_error_data( $res, $start_time, 'fs_connect' ); 731 733 $this->skin->error( $res ); 732 734 $this->skin->after(); 733 735 if ( ! $options['is_multi'] ) { … … class WP_Upgrader { 765 767 } 766 768 767 769 if ( is_wp_error( $download ) ) { 770 $this->send_error_data( $download, $start_time, 'download_package' ); 768 771 $this->skin->error( $download ); 769 772 $this->skin->after(); 770 773 if ( ! $options['is_multi'] ) { … … class WP_Upgrader { 778 781 // Unzips the file into a temporary directory. 779 782 $working_dir = $this->unpack_package( $download, $delete_package ); 780 783 if ( is_wp_error( $working_dir ) ) { 784 $this->send_error_data( $working_dir, $start_time, 'unpack_package' ); 781 785 $this->skin->error( $working_dir ); 782 786 $this->skin->after(); 783 787 if ( ! $options['is_multi'] ) { … … class WP_Upgrader { 800 804 801 805 $this->skin->set_result( $result ); 802 806 if ( is_wp_error( $result ) ) { 807 $this->send_error_data( $result, $start_time, 'install_package' ); 803 808 $this->skin->error( $result ); 804 809 805 810 if ( ! method_exists( $this->skin, 'hide_process_failed' ) || ! $this->skin->hide_process_failed( $result ) ) { … … class WP_Upgrader { 937 942 return delete_option( $lock_name . '.lock' ); 938 943 } 939 944 945 /** 946 * Send upgrade WP_Error data to WordPress.org. 947 * 948 * @since 5.7.0 949 * 950 * @global string $wp_version The WordPress version string. 951 * @global WP_Filesystem_Base $wp_filesystem WordPress filesystem subclass. 952 * @param WP_Error $result WP_Error data from failed upgrade process. 953 * @param int $start_time Time that run() started. 954 * @param string $method Name of method sending data. 955 * 956 * @return void 957 */ 958 public function send_error_data( $result, $start_time, $method = null ) { 959 global $wp_version, $wp_filesystem; 960 961 if ( ! is_wp_error( $result ) ) { 962 return; 963 } 964 $stats = array( 965 'process' => $method, 966 'update_type' => null, 967 'name' => null, 968 'update_version' => null, 969 'success' => false, 970 'fs_method' => $wp_filesystem->method, 971 'fs_method_forced' => defined( 'FS_METHOD' ) || has_filter( 'filesystem_method' ), 972 'fs_method_direct' => ! empty( $GLOBALS['_wp_filesystem_direct_method'] ) ? $GLOBALS['_wp_filesystem_direct_method'] : '', 973 'time_taken' => time() - $start_time, 974 'wp_version' => $wp_version, 975 'error_code' => $result->get_error_code(), 976 'error_message' => $result->get_error_message(), 977 'error_data' => $result->get_error_data(), 978 ); 979 if ( $this instanceof Plugin_Upgrader ) { 980 if ( isset( $this->skin->plugin_info ) ) { 981 $stats['update_type'] = 'manual_plugin_update'; 982 $stats['name'] = $this->skin->plugin_info['Name']; 983 $stats['update_version'] = $this->skin->plugin_info['Version']; 984 } else { 985 $stats['update_type'] = 'automatic_plugin_update'; 986 } 987 wp_update_plugins( $stats ); 988 } 989 if ( $this instanceof Theme_Upgrader ) { 990 if ( isset( $this->skin->theme_info )) { 991 $stats['update_type'] = 'manual_theme_update'; 992 $stats['name'] = $this->skin->theme_info->get('Name'); 993 $stats['update_version'] = $this->skin->theme_info->get('Version'); 994 } else { 995 $stats['update_type'] = 'automatic_theme_update'; 996 } 997 wp_update_themes( $stats ); 998 } 999 } 940 1000 } 941 1001 942 1002 /** Plugin_Upgrader class */