Site Health Check: Background updates not working as expected, extra line breaks

Hello!
In advance, I kindly ask that you not reply to this post until you have taken the time to read it thoroughly. The most important information is at the end.

My name is Stuart Simon, and I work for the Human Development Center at Louisiana State University Health Sciences Center. Last week I updated WordPress to version 5.4, and with Site Health Check, formerly a plugin, now integrated into core, I am getting the following error:

Background updates are not working as expected

Background updates ensure that WordPress can auto-update if a security update is released for the version you are currently using.

Error A plugin has prevented updates by disabling wp_version_check().
Passed No version control systems were detected.
Passed Your installation of WordPress doesn’t require FTP credentials to perform updates.
Passed All of your WordPress files are writable.

I’ve determined in my case that it is NOT related to loopback. Rather, I use an in-house theme. And this error appears ONLY when the in-house theme is active.

The code of the test that is failing:


/**
	 * Check if updates are intercepted by a filter.
	 *
	 * @since 5.2.0
	 *
	 * @return array The test results.
	 */
	public function test_wp_version_check_attached() {
		if ( ! is_main_site() ) {
			return;
		}

		$cookies = wp_unslash( $_COOKIE );
		$timeout = 10;
		$headers = array(
			'Cache-Control' => 'no-cache',
		);
		/** This filter is documented in wp-includes/class-wp-http-streams.php */
		$sslverify = apply_filters( 'https_local_ssl_verify', false );

		// Include Basic auth in loopback requests.
		if ( isset( $_SERVER['PHP_AUTH_USER'] ) && isset( $_SERVER['PHP_AUTH_PW'] ) ) {
			$headers['Authorization'] = 'Basic ' . base64_encode( wp_unslash( $_SERVER['PHP_AUTH_USER'] ) . ':' . wp_unslash( $_SERVER['PHP_AUTH_PW'] ) );
		}

		$url = add_query_arg(
			array(
				'health-check-test-wp_version_check' => true,
			),
			admin_url( 'site-health.php' )
		);

		$test = wp_remote_get( $url, compact( 'cookies', 'headers', 'timeout', 'sslverify' ) );

		if ( is_wp_error( $test ) ) {
			return array(
				'description' => sprintf(
					/* translators: %s: Name of the filter used. */
					__( 'Could not confirm that the %s filter is available.' ),
					'<code>wp_version_check()</code>'
				),
				'severity'    => 'warning',
			);
		}

		$response = wp_remote_retrieve_body( $test );

		if ( 'yes' !== $response ) {
			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',
			);
		}
	}

class-wp-site-health-auto-updates.php, lines 80-137

The underlying cause of the problem is that for some unexplained reason, the response that should be yes, with no whitespace before or after, has two leading line breaks. This is NOT true when the Twenty Twenty theme is active. But you should know that is IS true EVEN when I:

  1. Disable all plugins
  2. Delete all code from my theme’s functions.php file
  3. Fix my index.php file so that the entirety of its contents is Hello world!!! with no HTML or PHP tags
  4. Delete all files except functions.php, index.php, and style.css

So in essence I have nothing that could be adding the extra line breaks besides the theme itself, unless there is something else I should know about. Also, LSUHSC uses IIS, not Apache, so somebody knowledgeable about IIS might know something.

The page I need help with: [log in to see the link]



Source link