From 5188ab0ce79765def09d2ffcea74cf35c6d0f602 Mon Sep 17 00:00:00 2001 From: Sergey Biryukov Date: Thu, 15 Oct 2020 23:31:07 +0000 Subject: [PATCH] Upgrade/Install: Check if plugin or theme update results are available before applying the notification filters. This avoids a PHP notice for an undefined index of either `plugin` or `theme` in the `auto_{plugin|theme}_update_send_email` filter hook. Props afragen, audrasjb. Merges [49166] to the 5.5 branch. Fixes #51400. Built from https://develop.svn.wordpress.org/branches/5.5@49167 git-svn-id: http://core.svn.wordpress.org/branches/5.5@48929 1a063a9b-81f0-0310-95a4-ce76da25c4cd --- .../includes/class-wp-automatic-updater.php | 68 ++++++++++--------- wp-includes/version.php | 2 +- 2 files changed, 37 insertions(+), 33 deletions(-) diff --git a/wp-admin/includes/class-wp-automatic-updater.php b/wp-admin/includes/class-wp-automatic-updater.php index a51a36c5c8..02f1f8d4cf 100644 --- a/wp-admin/includes/class-wp-automatic-updater.php +++ b/wp-admin/includes/class-wp-automatic-updater.php @@ -887,44 +887,48 @@ class WP_Automatic_Updater { $successful_updates = array(); $failed_updates = array(); - /** - * Filters whether to send an email following an automatic background plugin update. - * - * @since 5.5.0 - * @since 5.5.1 Added the $update_results parameter. - * - * @param bool $enabled True if plugins notifications are enabled, false otherwise. - * @param array $update_results The results of plugins update tasks. - */ - $notifications_enabled = apply_filters( 'auto_plugin_update_send_email', true, $update_results['plugin'] ); + if ( ! empty( $update_results['plugin'] ) ) { + /** + * Filters whether to send an email following an automatic background plugin update. + * + * @since 5.5.0 + * @since 5.5.1 Added the `$update_results` parameter. + * + * @param bool $enabled True if plugin update notifications are enabled, false otherwise. + * @param array $update_results The results of plugins update tasks. + */ + $notifications_enabled = apply_filters( 'auto_plugin_update_send_email', true, $update_results['plugin'] ); - if ( ! empty( $update_results['plugin'] ) && $notifications_enabled ) { - foreach ( $update_results['plugin'] as $update_result ) { - if ( true === $update_result->result ) { - $successful_updates['plugin'][] = $update_result; - } else { - $failed_updates['plugin'][] = $update_result; + if ( $notifications_enabled ) { + foreach ( $update_results['plugin'] as $update_result ) { + if ( true === $update_result->result ) { + $successful_updates['plugin'][] = $update_result; + } else { + $failed_updates['plugin'][] = $update_result; + } } } } - /** - * Filters whether to send an email following an automatic background theme update. - * - * @since 5.5.0 - * @since 5.5.1 Added the $update_results parameter. - * - * @param bool $enabled True if notifications are enabled, false otherwise. - * @param array $update_results The results of theme update tasks. - */ - $notifications_enabled = apply_filters( 'auto_theme_update_send_email', true, $update_results['theme'] ); + if ( ! empty( $update_results['theme'] ) ) { + /** + * Filters whether to send an email following an automatic background theme update. + * + * @since 5.5.0 + * @since 5.5.1 Added the `$update_results` parameter. + * + * @param bool $enabled True if theme update notifications are enabled, false otherwise. + * @param array $update_results The results of theme update tasks. + */ + $notifications_enabled = apply_filters( 'auto_theme_update_send_email', true, $update_results['theme'] ); - if ( ! empty( $update_results['theme'] ) && $notifications_enabled ) { - foreach ( $update_results['theme'] as $update_result ) { - if ( true === $update_result->result ) { - $successful_updates['theme'][] = $update_result; - } else { - $failed_updates['theme'][] = $update_result; + if ( $notifications_enabled ) { + foreach ( $update_results['theme'] as $update_result ) { + if ( true === $update_result->result ) { + $successful_updates['theme'][] = $update_result; + } else { + $failed_updates['theme'][] = $update_result; + } } } } diff --git a/wp-includes/version.php b/wp-includes/version.php index 62a3d3848a..9ac99095db 100644 --- a/wp-includes/version.php +++ b/wp-includes/version.php @@ -13,7 +13,7 @@ * * @global string $wp_version */ -$wp_version = '5.5.2-alpha-49164'; +$wp_version = '5.5.2-alpha-49167'; /** * Holds the WordPress DB revision, increments when changes are made to the WordPress DB schema.