- Timestamp:
- 07/07/2020 06:58:32 PM (6 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/wp-admin/includes/class-wp-automatic-updater.php
r48344 r48397 940 940 if ( empty( $successful_updates ) && empty( $failed_updates ) ) { 941 941 return; 942 } 943 944 $unique_failures = false; 945 $past_failure_emails = get_option( 'auto_plugin_theme_update_emails', array() ); 946 947 // When only failures have occurred, an email should only be sent if there are unique failures. 948 // A failure is considered unique if an email has not been sent for an update attempt failure 949 // to a plugin or theme with the same new_version. 950 if ( 'fail' === $type ) { 951 foreach ( $failed_updates as $update_type => $failures ) { 952 foreach ( $failures as $failed_update ) { 953 if ( ! isset( $past_failure_emails[ $failed_update->item->{$update_type} ] ) ) { 954 $unique_failures = true; 955 continue; 956 } 957 958 // Check that the failure represents a new failure based on the new_version. 959 if ( version_compare( $past_failure_emails[ $failed_update->item->{$update_type} ], $failed_update->item->new_version, '<' ) ) { 960 $unique_failures = true; 961 } 962 } 963 } 964 965 if ( ! $unique_failures ) { 966 return; 967 } 942 968 } 943 969 … … 1018 1044 1019 1045 foreach ( $failed_updates['plugin'] as $item ) { 1020 $body[] = "- {$item->name}"; 1046 $body[] = "- {$item->name}"; 1047 $past_failure_emails[ $item->item->plugin ] = $item->item->new_version; 1021 1048 } 1022 1049 $body[] = "\n"; … … 1028 1055 1029 1056 foreach ( $failed_updates['theme'] as $item ) { 1030 $body[] = "- {$item->name}"; 1057 $body[] = "- {$item->name}"; 1058 $past_failure_emails[ $item->item->theme ] = $item->item->new_version; 1031 1059 } 1032 1060 $body[] = "\n"; … … 1044 1072 foreach ( $successful_updates['plugin'] as $item ) { 1045 1073 $body[] = "- {$item->name}"; 1074 unset( $past_failure_emails[ $item->item->plugin ] ); 1046 1075 } 1047 1076 $body[] = "\n"; … … 1054 1083 foreach ( $successful_updates['theme'] as $item ) { 1055 1084 $body[] = "- {$item->name}"; 1085 unset( $past_failure_emails[ $item->item->theme ] ); 1056 1086 } 1057 1087 $body[] = "\n"; … … 1109 1139 $email = apply_filters( 'auto_plugin_theme_update_email', $email, $type, $successful_updates, $failed_updates ); 1110 1140 1111 wp_mail( $email['to'], wp_specialchars_decode( $email['subject'] ), $email['body'], $email['headers'] ); 1141 $result = wp_mail( $email['to'], wp_specialchars_decode( $email['subject'] ), $email['body'], $email['headers'] ); 1142 1143 if ( $result ) { 1144 update_option( 'auto_plugin_theme_update_emails', $past_failure_emails ); 1145 } 1112 1146 } 1113 1147
Note: See TracChangeset
for help on using the changeset viewer.