From 1627abae6154b135ade5a931184aa17010bad80d Mon Sep 17 00:00:00 2001
From: Paul Biron <paul@sparrowhawkcomputing.com>
Date: Thu, 3 Dec 2020 15:29:52 -0700
Subject: [PATCH] Send stats to the API when plugin or theme update fails.
---
src/wp-admin/includes/class-wp-upgrader.php | 32 +++++++++++++++++++++
1 file changed, 32 insertions(+)
diff --git a/src/wp-admin/includes/class-wp-upgrader.php b/src/wp-admin/includes/class-wp-upgrader.php
index 5faac56213..4563afc63d 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 { |
| 798 | 799 | ) |
| 799 | 800 | ); |
| 800 | 801 | |
| | 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'] ) ? $GLOB['_wp_filesystem_direct_method'] : '', |
| | 813 | 'time_taken' => time() - $start_time, |
| | 814 | 'wp_version' => $wp_version, |
| | 815 | 'wp_error' => $result, |
| | 816 | ); |
| | 817 | if ( $this instanceof Plugin_Upgrader ) { |
| | 818 | $stats['update_type'] = 'plugin'; |
| | 819 | $stats['name'] = $this->skin->plugin_info['Name']; |
| | 820 | $stats['update_version'] = $this->skin->plugin_info['Version']; |
| | 821 | |
| | 822 | wp_update_plugins( $stats ); |
| | 823 | } |
| | 824 | if ( $this instanceof Theme_Upgrader ) { |
| | 825 | $stats['update_type'] = 'theme'; |
| | 826 | $stats['name'] = $this->skin->theme_info->get('Name'); |
| | 827 | $stats['update_version'] = $this->skin->theme_info->get('Version'); |
| | 828 | |
| | 829 | wp_update_themes( $stats ); |
| | 830 | } |
| | 831 | } |
| | 832 | |
| 801 | 833 | $this->skin->set_result( $result ); |
| 802 | 834 | if ( is_wp_error( $result ) ) { |
| 803 | 835 | $this->skin->error( $result ); |