WordPress.org

Make WordPress Core

Opened 7 months ago

Closed 6 months ago

Last modified 6 months ago

#52135 closed defect (bug) (fixed)

False positive on `WP_Site_Health_Auto_Updates`

Reported by: audrasjb Owned by: whyisjake
Milestone: 5.6.1 Priority: normal
Severity: normal Version: 5.6
Component: Site Health Keywords: has-patch has-screenshots commit
Focuses: multisite Cc:

Description

It looks like there is a false positive on WP_Site_Health_Auto_Updates check, which trigger "Background updates are not working as expected" notice on Site Health screen.

The issue only occurs on Multisite installations, and doesn't appear on the main site of the network, only on other ones.

I was able to reproduce the issue on several existing networks.
It looks like the issue appeared in WP 5.6, so let's milestone this for the next point release.

Committers: please don't forget to props @aaribaud who first reported the issue on WordPress.org support forums: https://wordpress.org/support/topic/wp-complaining-about-its-own-wp_version_check-filter/

This forum topic also contains some research the original reporter did on their side. Worth a read :)

Attachments (2)

Capture d’écran 2020-12-20 à 20.00.29.png (92.6 KB) - added by audrasjb 7 months ago.
Site health false positive on WP_Site_Health_Auto_Updates
52135.1.diff (758 bytes) - added by maxpertici 6 months ago.
update the test_wp_version_check_attached() function class-wp-site-health-auto-updates.php.

Download all attachments as: .zip

Change History (15)

@audrasjb
7 months ago

Site health false positive on WP_Site_Health_Auto_Updates

#2 @SergeyBiryukov
7 months ago

  • Focuses multisite added

Thanks for the report!

The issue only occurs on Multisite installations, and doesn't appear on the main site of the network, only on other ones.

As noted in the thread, this was introduced with the ! has_filter( 'wp_version_check', 'wp_version_check' ) condition in [49154].

wp-includes/update.php does set up the action, but only for the main site:

if ( ( ! is_main_site() && ! is_network_admin() ) || wp_doing_ajax() ) {
	return;
}

add_action( 'wp_version_check', 'wp_version_check' );
Last edited 7 months ago by SergeyBiryukov (previous) (diff)

#3 @SergeyBiryukov
7 months ago

#52203 was marked as a duplicate.

This ticket was mentioned in Slack in #core-site-health by audrasjb. View the logs.


7 months ago

#5 @maxpertici
6 months ago

Hello, I reproduced the bug well and did some tests.
I did two quick tests to see the result and modify the condition, the error persists.

For example with

if ( ! is_network_admin() || wp_doing_ajax() ) {
	return;
}

or

if ( ! is_admin() || wp_doing_ajax() ) {
	return;
}

The error is still displayed in the Site Health.

I am attaching a patch where this time the wp_version_check test is run only for the main site if site is multisite.

I updated the test_wp_version_check_attached() function class-wp-site-health-auto-updates.php.

public function test_wp_version_check_attached() {
	if ( ( ! is_multisite() || ( is_main_site() && is_network_admin() ) ) && ! has_filter( 'wp_version_check', 'wp_version_check' ) ) {
		return array(
			'description' => sprintf(
				/* translators: %s: Name of the filter used. */
				__( 'A plugin has prevented updates by disabling %s.' ),
				'<code>wp_version_check()</code>'
			),
			'severity'    => 'fail',
		);
	}
}

@maxpertici
6 months ago

update the test_wp_version_check_attached() function class-wp-site-health-auto-updates.php.

#6 @audrasjb
6 months ago

  • Keywords has-patch has-screenshots added; needs-patch removed

The patch looks good to me 👍

This ticket was mentioned in Slack in #core by audrasjb. View the logs.


6 months ago

#8 @audrasjb
6 months ago

  • Keywords commit added

#9 @audrasjb
6 months ago

Marking for commit as per today's bug scrub

#10 @whyisjake
6 months ago

  • Owner set to whyisjake
  • Resolution set to fixed
  • Status changed from new to closed

In 50035:

Site Health: Only run the version checks on the main site.

The version checks that are setup in wp-includes/update.php do set up the action, but only for the main site.

Fixes #52135.

Props audrasjb, SergeyBiryukov, maxpertici, aaribaud.

#11 @whyisjake
6 months ago

In 50036:

Site Health: Only run the version checks on the main site.

The version checks that are setup in wp-includes/update.php do set up the action, but only for the main site.

This brings the changes in [50035] to the 5.6 branch.

Fixes #52135.

Props audrasjb, SergeyBiryukov, maxpertici, aaribaud.

#12 @SergeyBiryukov
6 months ago

In 50049:

Coding Standards: Simplify a long condition in WP_Site_Health_Auto_Updates::test_wp_version_check_attached() for better readability.

Follow-up to [50035].

See #52135.

#13 @SergeyBiryukov
6 months ago

In 50050:

Coding Standards: Simplify a long condition in WP_Site_Health_Auto_Updates::test_wp_version_check_attached() for better readability.

Follow-up to [50035].

Merges [50049] to the 5.6 branch.
See #52135.

Note: See TracTickets for help on using tickets.