Make WordPress Core

Ticket #51928: 51928.3.2.diff

File 51928.3.2.diff, 2.4 KB (added by afragen, 4 years ago)

pass at identifying automatic vs manual update

  • 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..6b437dceb5 100644
    a b class WP_Upgrader { 
    666666         *                              or false if unable to connect to the filesystem.
    667667         */
    668668        public function run( $options ) {
     669                $start_time = time();
    669670
    670671                $defaults = array(
    671672                        'package'                     => '', // Please always pass this.
    class WP_Upgrader { 
    798799                        )
    799800                );
    800801
     802                // If WP_Error send data to WordPress.org.
     803                if ( is_wp_error( $result ) ) {
     804                        global $wp_version, $wp_filesystem;
     805                        $stats = array(
     806                                'update_type'      => null,
     807                                'name'             => null,
     808                                'update_version'   => null,
     809                                'success'          => false,
     810                                'fs_method'        => $wp_filesystem->method,
     811                                'fs_method_forced' => defined( 'FS_METHOD' ) || has_filter( 'filesystem_method' ),
     812                                'fs_method_direct' => ! empty( $GLOBALS['_wp_filesystem_direct_method'] ) ? $GLOBALS['_wp_filesystem_direct_method'] : '',
     813                                'time_taken'       => time() - $start_time,
     814                                'wp_version'       => $wp_version,
     815                                'error_code'       => $result->get_error_code(),
     816                                'error_message'    => $result->get_error_message(),
     817                                'error_data'       => $result->get_error_data(),
     818                        );
     819                        if ( $this instanceof Plugin_Upgrader ) {
     820                                if ( $this->skin instanceof Automatic_Upgrader_Skin ) {
     821                                        $stats['update_type'] = 'automatic_plugin_update';
     822                                }
     823                                if ( $this->skin instanceof Plugin_Upgrader_Skin ) {
     824                                        $stats['update_type']    = 'manual_plugin_update';
     825                                        $stats['name']           = $this->skin->plugin_info['Name'];
     826                                        $stats['update_version'] = $this->skin->plugin_info['Version'];
     827                                }
     828                                wp_update_plugins( $stats );
     829                        }
     830                        if ( $this instanceof Theme_Upgrader ) {
     831                                if ( $this->skin instanceof Automatic_Upgrader_Skin ) {
     832                                        $stats['update_type'] = 'automatic_theme_update';
     833                                }
     834                                if ( $this->skin instanceof Theme_Upgrader_Skin ) {
     835                                        $stats['update_type']    = 'manual_theme_update';
     836                                        $stats['name']           = $this->skin->theme_info->get('Name');
     837                                        $stats['update_version'] = $this->skin->theme_info->get('Version');
     838                                }
     839                                wp_update_themes( $stats );
     840                        }
     841                }
     842
    801843                $this->skin->set_result( $result );
    802844                if ( is_wp_error( $result ) ) {
    803845                        $this->skin->error( $result );