From c0d3d7627be830ac074acc64278dacad8b02aed6 Mon Sep 17 00:00:00 2001 From: Jonathan Desrosiers Date: Thu, 23 Jul 2020 19:01:24 +0000 Subject: [PATCH] Site Health: Pass all expected parameters to `auto_update_{$type}`. This prevents fatal errors when other hooked functions are expecting both parameters. Props dd32, desrosj, audrasjb, pbiron. Fixes #50662. git-svn-id: https://develop.svn.wordpress.org/trunk@48584 602fd350-edb4-49c9-b593-d223f7449a82 --- .../includes/class-wp-site-health.php | 34 +++++++++++++++++-- 1 file changed, 32 insertions(+), 2 deletions(-) diff --git a/src/wp-admin/includes/class-wp-site-health.php b/src/wp-admin/includes/class-wp-site-health.php index 4cfa8de901..f5495cb3f4 100644 --- a/src/wp-admin/includes/class-wp-site-health.php +++ b/src/wp-admin/includes/class-wp-site-health.php @@ -2342,10 +2342,40 @@ class WP_Site_Health { * @return object The test results. */ function detect_plugin_theme_auto_update_issues() { + $mock_plugin = (object) array( + 'id' => 'w.org/plugins/a-fake-plugin', + 'slug' => 'a-fake-plugin', + 'plugin' => 'a-fake-plugin/a-fake-plugin.php', + 'new_version' => '9.9', + 'url' => 'https://wordpress.org/plugins/a-fake-plugin', + 'package' => 'https://downloads.wordpress.org/plugin/a-fake-plugin.9.9.zip', + 'icons' => array( + '2x' => 'https://ps.w.org/a-fake-plugin/assets/icon-256x256.png', + '1x' => 'https://ps.w.org/a-fake-plugin/assets/icon-128x128.png', + ), + 'banners' => array( + '2x' => 'https://ps.w.org/a-fake-plugin/assets/banner-1544x500.png', + '1x' => 'https://ps.w.org/a-fake-plugin/assets/banner-772x250.png', + ), + 'banners_rtl' => array(), + 'tested' => `5.5.0`, + 'requires_php' => '5.6.20', + 'compatibility' => new stdClass(), + ); + + $mock_theme = (object) array( + 'theme' => 'a-fake-theme', + 'new_version' => '9.9', + 'url' => 'https://wordpress.org/themes/a-fake-theme/', + 'package' => 'https://downloads.wordpress.org/theme/a-fake-theme.9.9.zip', + 'requires' => '5.0.0', + 'requires_php' => '5.6.20', + ); + /** This filter is documented in wp-admin/includes/class-wp-automatic-updater.php */ - $test_plugins_enabled = apply_filters( 'auto_update_plugin', true ); + $test_plugins_enabled = apply_filters( 'auto_update_plugin', true, $mock_plugin ); /** This filter is documented in wp-admin/includes/class-wp-automatic-updater.php */ - $test_themes_enabled = apply_filters( 'auto_update_theme', true ); + $test_themes_enabled = apply_filters( 'auto_update_theme', true, $mock_theme ); $ui_enabled_for_plugins = wp_is_auto_update_enabled_for_type( 'plugin' ); $ui_enabled_for_themes = wp_is_auto_update_enabled_for_type( 'theme' ); $plugin_filter_present = has_filter( 'auto_update_plugin' );