| | 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 | } |