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
This commit is contained in:
Jonathan Desrosiers 2020-07-23 19:01:24 +00:00
parent 7ddd0a5702
commit c0d3d7627b

View File

@ -2342,10 +2342,40 @@ class WP_Site_Health {
* @return object The test results. * @return object The test results.
*/ */
function detect_plugin_theme_auto_update_issues() { 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 */ /** 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 */ /** 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_plugins = wp_is_auto_update_enabled_for_type( 'plugin' );
$ui_enabled_for_themes = wp_is_auto_update_enabled_for_type( 'theme' ); $ui_enabled_for_themes = wp_is_auto_update_enabled_for_type( 'theme' );
$plugin_filter_present = has_filter( 'auto_update_plugin' ); $plugin_filter_present = has_filter( 'auto_update_plugin' );