mirror of
https://github.com/gosticks/wordpress-develop.git
synced 2026-04-14 17:44:25 +00:00
Administration: Prevent repeat emails for identical plugin or theme auto-update attempt failures.
This change adds a throttle mechanism to plugin and theme auto-update failure emails using similar logic to the email sent for a Core auto-update. The first time a plugin or theme auto-update fails, the package and `new_version` will be tracked in the `auto_plugin_theme_update_emails` option. An email for this specific update attempt will not be resent. However, if this update fails again and non-repeat failures or successful updates are also present, then the failure information will be included in that email (an email needs to be sent for the new events regardless). Props johnbillion, arpitgshah, desrosj, audrasjb, pbiron, earnjam. Fixes #50448. git-svn-id: https://develop.svn.wordpress.org/trunk@48397 602fd350-edb4-49c9-b593-d223f7449a82
This commit is contained in:
@@ -247,6 +247,15 @@ class Plugin_Upgrader extends WP_Upgrader {
|
||||
// Force refresh of plugin update information.
|
||||
wp_clean_plugins_cache( $parsed_args['clear_update_cache'] );
|
||||
|
||||
// Ensure any future auto-update failures trigger a failure email by removing the last
|
||||
// failure notification from the list when plugins update successfully.
|
||||
$past_failure_emails = get_option( 'auto_plugin_theme_update_emails', array() );
|
||||
|
||||
if ( isset( $past_failure_emails[ $plugin ] ) ) {
|
||||
unset( $past_failure_emails[ $plugin ] );
|
||||
update_option( 'auto_plugin_theme_update_emails', $past_failure_emails );
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
@@ -370,6 +379,20 @@ class Plugin_Upgrader extends WP_Upgrader {
|
||||
// Cleanup our hooks, in case something else does a upgrade on this connection.
|
||||
remove_filter( 'upgrader_clear_destination', array( $this, 'delete_old_plugin' ) );
|
||||
|
||||
// Ensure any future auto-update failures trigger a failure email by removing the last
|
||||
// failure notification from the list when plugins update successfully.
|
||||
$past_failure_emails = get_option( 'auto_plugin_theme_update_emails', array() );
|
||||
|
||||
foreach ( $results as $plugin => $result ) {
|
||||
// Maintain last failure notification when plugins failed to update manually.
|
||||
if ( ! $result || is_wp_error( $result ) || ! isset( $past_failure_emails[ $plugin ] ) ) {
|
||||
continue;
|
||||
}
|
||||
|
||||
unset( $past_failure_emails[ $plugin ] );
|
||||
}
|
||||
update_option( 'auto_plugin_theme_update_emails', $past_failure_emails );
|
||||
|
||||
return $results;
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user