Ticket #50448: 50448.diff
| File 50448.diff, 6.2 KB (added by , 6 years ago) |
|---|
-
src/wp-admin/includes/class-plugin-upgrader.php
205 205 // Force refresh of plugin update information. 206 206 wp_clean_plugins_cache( $parsed_args['clear_update_cache'] ); 207 207 208 // Ensure any new auto-update failures trigger a failure email when plugins update successfully. 209 $past_failure_emails = get_option( 'auto_plugin_theme_update_emails', array() ); 210 211 if ( isset( $past_failure_emails[ $plugin ] ) ) { 212 unset( $past_failure_emails[ $plugin ] ); 213 update_option( 'auto_plugin_theme_update_emails', $past_failure_emails ); 214 } 215 208 216 return true; 209 217 } 210 218 … … 329 337 // Cleanup our hooks, in case something else does a upgrade on this connection. 330 338 remove_filter( 'upgrader_clear_destination', array( $this, 'delete_old_plugin' ) ); 331 339 340 // Ensure any new auto-update failures trigger a failure email when plugins update successfully. 341 $past_failure_emails = get_option( 'auto_plugin_theme_update_emails', array() ); 342 343 foreach ( $results as $plugin => $result ) { 344 // Maintain last failure notification when plugins failed to update manually. 345 if ( ! isset( $past_failure_emails[ $plugin ] ) || ! $result || is_wp_error( $result ) ) { 346 continue; 347 } 348 349 unset( $past_failure_emails[ $plugin ] ); 350 } 351 update_option( 'auto_plugin_theme_update_emails', $past_failure_emails ); 352 332 353 return $results; 333 354 } 334 355 -
src/wp-admin/includes/class-wp-automatic-updater.php
941 941 return; 942 942 } 943 943 944 $unique_failures = false; 945 $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 either new failures, 948 // or failures that have not sent out an email recently. 949 if ( 'fail' === $type ) { 950 $unique_failures = false; 951 952 /** 953 * Filters the time interval between failure emails for a plugin. 954 * 955 * This prevents a site owner from receiving an email notice every time 956 * the auto-update routine runs (every 12 hours by default). 957 * 958 * @param int $time Time interval in seconds between failure notifications. 959 * Default is 259,200 (3 days). 960 */ 961 $failure_email_interval = apply_filters( 'auto_plugin_theme_update_email_fail_interval', DAY_IN_SECONDS * 3 ); 962 963 foreach ( $failed_updates as $update_type => $failures ) { 964 foreach ( $failures as $failed_update ) { 965 if ( ! isset( $failure_emails[ $failed_update->item->{$update_type} ] ) ) { 966 $unique_failures = true; 967 continue; 968 } 969 970 // Enough time has passed to make this failure warrant an email. 971 if ( time() - $failure_emails[ $failed_update->item->{$update_type} ] > $failure_email_interval ) { 972 $unique_failures = true; 973 } 974 } 975 } 976 977 if ( ! $unique_failures ) { 978 return; 979 } 980 } 981 944 982 $body = array(); 945 983 $successful_plugins = ( ! empty( $successful_updates['plugin'] ) ); 946 984 $successful_themes = ( ! empty( $successful_updates['theme'] ) ); … … 1017 1055 $body[] = __( 'These plugins failed to update:' ); 1018 1056 1019 1057 foreach ( $failed_updates['plugin'] as $item ) { 1020 $body[] = "- {$item->name}"; 1058 $body[] = "- {$item->name}"; 1059 $failure_emails[ $item->item->plugin ] = time(); 1021 1060 } 1022 1061 $body[] = "\n"; 1023 1062 } … … 1027 1066 $body[] = __( 'These themes failed to update:' ); 1028 1067 1029 1068 foreach ( $failed_updates['theme'] as $item ) { 1030 $body[] = "- {$item->name}"; 1069 $body[] = "- {$item->name}"; 1070 $failure_emails[ $item->item->theme ] = time(); 1031 1071 } 1032 1072 $body[] = "\n"; 1033 1073 } … … 1043 1083 1044 1084 foreach ( $successful_updates['plugin'] as $item ) { 1045 1085 $body[] = "- {$item->name}"; 1086 unset( $failure_emails[ $item->item->plugin ] ); 1046 1087 } 1047 1088 $body[] = "\n"; 1048 1089 } … … 1053 1094 // List successful updates. 1054 1095 foreach ( $successful_updates['theme'] as $item ) { 1055 1096 $body[] = "- {$item->name}"; 1097 unset( $failure_emails[ $item->item->theme ] ); 1056 1098 } 1057 1099 $body[] = "\n"; 1058 1100 } … … 1108 1150 */ 1109 1151 $email = apply_filters( 'auto_plugin_theme_update_email', $email, $type, $successful_updates, $failed_updates ); 1110 1152 1111 wp_mail( $email['to'], wp_specialchars_decode( $email['subject'] ), $email['body'], $email['headers'] ); 1153 $result = wp_mail( $email['to'], wp_specialchars_decode( $email['subject'] ), $email['body'], $email['headers'] ); 1154 1155 if ( $result ) { 1156 update_option( 'auto_plugin_theme_update_emails', $failure_emails ); 1157 } 1112 1158 } 1113 1159 1114 1160 /** -
src/wp-admin/includes/schema.php
534 534 // 5.5.0 535 535 'blocklist_keys' => '', 536 536 'comment_previously_approved' => 1, 537 'auto_plugin_theme_update_emails' => array(), 537 538 ); 538 539 539 540 // 3.3.0 … … 552 553 $options = wp_parse_args( $options, $defaults ); 553 554 554 555 // Set autoload to no for these options. 555 $fat_options = array( 'moderation_keys', 'recently_edited', 'blocklist_keys', 'uninstall_plugins' ); 556 $fat_options = array( 557 'moderation_keys', 558 'recently_edited', 559 'blocklist_keys', 560 'uninstall_plugins', 561 'auto_plugin_theme_update_emails', 562 ); 556 563 557 564 $keys = "'" . implode( "', '", array_keys( $options ) ) . "'"; 558 565 $existing_options = $wpdb->get_col( "SELECT option_name FROM $wpdb->options WHERE option_name in ( $keys )" ); // phpcs:ignore WordPress.DB.PreparedSQL.NotPrepared -
src/wp-includes/version.php
20 20 * 21 21 * @global int $wp_db_version 22 22 */ 23 $wp_db_version = 48 121;23 $wp_db_version = 48337; 24 24 25 25 /** 26 26 * Holds the TinyMCE version.