Ticket #51928: 51928.8.diff
File 51928.8.diff, 10.5 KB (added by , 4 years ago) |
---|
-
wp-admin/includes/class-plugin-upgrader.php
diff --git a/wp-admin/includes/class-plugin-upgrader.php b/wp-admin/includes/class-plugin-upgrader.php index b171f9228b..0e1c185daa 100644
a b class Plugin_Upgrader extends WP_Upgrader { 116 116 * @return bool|WP_Error True if the installation was successful, false or a WP_Error otherwise. 117 117 */ 118 118 public function install( $package, $args = array() ) { 119 $start_time = time(); 119 120 $defaults = array( 120 121 'clear_update_cache' => true, 121 122 'overwrite_package' => false, // Do not overwrite files. … … class Plugin_Upgrader extends WP_Upgrader { 132 133 add_action( 'upgrader_process_complete', 'wp_clean_plugins_cache', 9, 0 ); 133 134 } 134 135 135 $ this->run(136 $result = $this->run( 136 137 array( 137 138 'package' => $package, 138 139 'destination' => WP_PLUGIN_DIR, … … class Plugin_Upgrader extends WP_Upgrader { 148 149 remove_action( 'upgrader_process_complete', 'wp_clean_plugins_cache', 9 ); 149 150 remove_filter( 'upgrader_source_selection', array( $this, 'check_package' ) ); 150 151 152 if ( is_wp_error( $result ) ) { 153 $this->send_error_data( $result, $start_time, 'plugin_install' ); 154 } 155 151 156 if ( ! $this->result || is_wp_error( $this->result ) ) { 152 157 return $this->result; 153 158 } … … class Plugin_Upgrader extends WP_Upgrader { 188 193 * @return bool|WP_Error True if the upgrade was successful, false or a WP_Error object otherwise. 189 194 */ 190 195 public function upgrade( $plugin, $args = array() ) { 196 $start_time = time(); 191 197 $defaults = array( 192 198 'clear_update_cache' => true, 193 199 ); … … class Plugin_Upgrader extends WP_Upgrader { 219 225 add_action( 'upgrader_process_complete', 'wp_clean_plugins_cache', 9, 0 ); 220 226 } 221 227 222 $ this->run(228 $result = $this->run( 223 229 array( 224 230 'package' => $r->package, 225 231 'destination' => WP_PLUGIN_DIR, … … class Plugin_Upgrader extends WP_Upgrader { 240 246 remove_filter( 'upgrader_clear_destination', array( $this, 'delete_old_plugin' ) ); 241 247 remove_filter( 'upgrader_post_install', array( $this, 'active_after' ) ); 242 248 249 if ( is_wp_error( $result ) ) { 250 $this->send_error_data( $result, $start_time, 'plugin_upgrade' ); 251 } 252 243 253 if ( ! $this->result || is_wp_error( $this->result ) ) { 244 254 return $this->result; 245 255 } … … class Plugin_Upgrader extends WP_Upgrader { 274 284 * @return array|false An array of results indexed by plugin file, or false if unable to connect to the filesystem. 275 285 */ 276 286 public function bulk_upgrade( $plugins, $args = array() ) { 287 $start_time = time(); 277 288 $defaults = array( 278 289 'clear_update_cache' => true, 279 290 ); … … class Plugin_Upgrader extends WP_Upgrader { 349 360 350 361 $results[ $plugin ] = $this->result; 351 362 363 if ( is_wp_error( $result ) ) { 364 $this->send_error_data( $result, $start_time, 'plugin_bulk_upgrade' ); 365 } 366 352 367 // Prevent credentials auth screen from displaying multiple times. 353 368 if ( false === $result ) { 354 369 break; -
wp-admin/includes/class-theme-upgrader.php
diff --git a/wp-admin/includes/class-theme-upgrader.php b/wp-admin/includes/class-theme-upgrader.php index 229a8115bd..f1ff035f06 100644
a b class Theme_Upgrader extends WP_Upgrader { 122 122 * @return bool 123 123 */ 124 124 public function check_parent_theme_filter( $install_result, $hook_extra, $child_result ) { 125 $start_time = time(); 126 125 127 // Check to see if we need to install a parent theme. 126 128 $theme_info = $this->theme_info(); 127 129 … … class Theme_Upgrader extends WP_Upgrader { 180 182 ); 181 183 182 184 if ( is_wp_error( $parent_result ) ) { 185 $this->send_error_data( $parent_result, $start_time, 'parent_theme' ); 183 186 add_filter( 'install_theme_complete_actions', array( $this, 'hide_activate_preview_actions' ) ); 184 187 } 185 188 … … class Theme_Upgrader extends WP_Upgrader { 228 231 * @return bool|WP_Error True if the installation was successful, false or a WP_Error object otherwise. 229 232 */ 230 233 public function install( $package, $args = array() ) { 234 $start_time = time(); 231 235 $defaults = array( 232 236 'clear_update_cache' => true, 233 237 'overwrite_package' => false, // Do not overwrite files. … … class Theme_Upgrader extends WP_Upgrader { 245 249 add_action( 'upgrader_process_complete', 'wp_clean_themes_cache', 9, 0 ); 246 250 } 247 251 248 $ this->run(252 $result = $this->run( 249 253 array( 250 254 'package' => $package, 251 255 'destination' => get_theme_root(), … … class Theme_Upgrader extends WP_Upgrader { 262 266 remove_filter( 'upgrader_source_selection', array( $this, 'check_package' ) ); 263 267 remove_filter( 'upgrader_post_install', array( $this, 'check_parent_theme_filter' ) ); 264 268 269 if ( is_wp_error( $result ) ) { 270 $this->send_error_data( $result, $start_time, 'theme_install' ); 271 } 272 265 273 if ( ! $this->result || is_wp_error( $this->result ) ) { 266 274 return $this->result; 267 275 } … … class Theme_Upgrader extends WP_Upgrader { 302 310 * @return bool|WP_Error True if the upgrade was successful, false or a WP_Error object otherwise. 303 311 */ 304 312 public function upgrade( $theme, $args = array() ) { 313 $start_time = time(); 305 314 $defaults = array( 306 315 'clear_update_cache' => true, 307 316 ); … … class Theme_Upgrader extends WP_Upgrader { 330 339 add_action( 'upgrader_process_complete', 'wp_clean_themes_cache', 9, 0 ); 331 340 } 332 341 333 $ this->run(342 $result = $this->run( 334 343 array( 335 344 'package' => $r['package'], 336 345 'destination' => get_theme_root( $theme ), … … class Theme_Upgrader extends WP_Upgrader { 349 358 remove_filter( 'upgrader_post_install', array( $this, 'current_after' ) ); 350 359 remove_filter( 'upgrader_clear_destination', array( $this, 'delete_old_theme' ) ); 351 360 361 if ( is_wp_error( $result ) ) { 362 $this->send_error_data( $result, $start_time, 'theme_upgrade' ); 363 } 364 352 365 if ( ! $this->result || is_wp_error( $this->result ) ) { 353 366 return $this->result; 354 367 } … … class Theme_Upgrader extends WP_Upgrader { 383 396 * @return array[]|false An array of results, or false if unable to connect to the filesystem. 384 397 */ 385 398 public function bulk_upgrade( $themes, $args = array() ) { 399 $start_time = time(); 386 400 $defaults = array( 387 401 'clear_update_cache' => true, 388 402 ); … … class Theme_Upgrader extends WP_Upgrader { 459 473 460 474 $results[ $theme ] = $this->result; 461 475 476 if ( is_wp_error( $result ) ) { 477 $this->send_error_data( $result, $start_time, 'theme_bulk_upgrade' ); 478 } 479 462 480 // Prevent credentials auth screen from displaying multiple times. 463 481 if ( false === $result ) { 464 482 break; -
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 */