Ticket #50448: 50448.3.diff
| File 50448.3.diff, 7.3 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 future 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 future 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 ( ! $result || is_wp_error( $result ) || ! isset( $past_failure_emails[ $plugin ] ) ) { 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-theme-upgrader.php
313 313 314 314 wp_clean_themes_cache( $parsed_args['clear_update_cache'] ); 315 315 316 // Ensure any future auto-update failures trigger a failure email when themes update successfully. 317 $past_failure_emails = get_option( 'auto_plugin_theme_update_emails', array() ); 318 319 if ( isset( $past_failure_emails[ $theme ] ) ) { 320 unset( $past_failure_emails[ $theme ] ); 321 update_option( 'auto_plugin_theme_update_emails', $past_failure_emails ); 322 } 323 316 324 return true; 317 325 } 318 326 … … 441 449 remove_filter( 'upgrader_post_install', array( $this, 'current_after' ) ); 442 450 remove_filter( 'upgrader_clear_destination', array( $this, 'delete_old_theme' ) ); 443 451 452 // Ensure any future auto-update failures trigger a failure email when themes update successfully. 453 $past_failure_emails = get_option( 'auto_plugin_theme_update_emails', array() ); 454 455 foreach ( $results as $theme => $result ) { 456 // Maintain last failure notification when themes failed to update manually. 457 if ( ! $result || is_wp_error( $result ) || ! isset( $past_failure_emails[ $theme ] ) ) { 458 continue; 459 } 460 461 unset( $past_failure_emails[ $theme ] ); 462 } 463 update_option( 'auto_plugin_theme_update_emails', $past_failure_emails ); 464 444 465 return $results; 445 466 } 446 467 -
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 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( $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( $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 } 968 } 969 944 970 $body = array(); 945 971 $successful_plugins = ( ! empty( $successful_updates['plugin'] ) ); 946 972 $successful_themes = ( ! empty( $successful_updates['theme'] ) ); … … 1017 1043 $body[] = __( 'These plugins failed to update:' ); 1018 1044 1019 1045 foreach ( $failed_updates['plugin'] as $item ) { 1020 $body[] = "- {$item->name}"; 1046 $body[] = "- {$item->name}"; 1047 $failure_emails[ $item->item->plugin ] = $item->item->new_version; 1021 1048 } 1022 1049 $body[] = "\n"; 1023 1050 } … … 1027 1054 $body[] = __( 'These themes failed to update:' ); 1028 1055 1029 1056 foreach ( $failed_updates['theme'] as $item ) { 1030 $body[] = "- {$item->name}"; 1057 $body[] = "- {$item->name}"; 1058 $failure_emails[ $item->item->theme ] = $item->item->new_version; 1031 1059 } 1032 1060 $body[] = "\n"; 1033 1061 } … … 1043 1071 1044 1072 foreach ( $successful_updates['plugin'] as $item ) { 1045 1073 $body[] = "- {$item->name}"; 1074 unset( $failure_emails[ $item->item->plugin ] ); 1046 1075 } 1047 1076 $body[] = "\n"; 1048 1077 } … … 1053 1082 // List successful updates. 1054 1083 foreach ( $successful_updates['theme'] as $item ) { 1055 1084 $body[] = "- {$item->name}"; 1085 unset( $failure_emails[ $item->item->theme ] ); 1056 1086 } 1057 1087 $body[] = "\n"; 1058 1088 } … … 1108 1138 */ 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', $failure_emails ); 1145 } 1112 1146 } 1113 1147 1114 1148 /** -
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.