diff --git a/src/wp-admin/includes/class-wp-site-health.php b/src/wp-admin/includes/class-wp-site-health.php index 2ddfaadc4b39d..de0a77fb42c06 100644 --- a/src/wp-admin/includes/class-wp-site-health.php +++ b/src/wp-admin/includes/class-wp-site-health.php @@ -2802,7 +2802,8 @@ public function get_test_opcode_cache(): array { $opcode_cache_enabled = false; if ( function_exists( 'opcache_get_status' ) ) { $status = @opcache_get_status( false ); // phpcs:ignore WordPress.PHP.NoSilencedErrors.Discouraged -- Warning emitted in failure case. - if ( $status && true === $status['opcache_enabled'] ) { + // OPcache reports `opcache_enabled` as false when only the file cache is in use, though that is still an active opcode cache. + if ( $status && ( true === $status['opcache_enabled'] || ! empty( $status['file_cache_only'] ) ) ) { $opcode_cache_enabled = true; } } diff --git a/tests/phpunit/tests/admin/wpSiteHealth.php b/tests/phpunit/tests/admin/wpSiteHealth.php index 6080b477f54c3..5dd1198ec1d09 100644 --- a/tests/phpunit/tests/admin/wpSiteHealth.php +++ b/tests/phpunit/tests/admin/wpSiteHealth.php @@ -684,6 +684,7 @@ public function test_get_test_opcode_cache_return_structure() { * Covers: opcache enabled, disabled, not available, and opcache_get_status() returns false. * * @ticket 63697 + * @ticket 65921 * * @covers ::get_test_opcode_cache() */ @@ -693,7 +694,7 @@ public function test_get_test_opcode_cache_result_by_environment() { $opcache_enabled = false; if ( function_exists( 'opcache_get_status' ) ) { $status = @opcache_get_status( false ); // phpcs:ignore WordPress.PHP.NoSilencedErrors.Discouraged -- Warning emitted in failure case. - if ( $status && true === $status['opcache_enabled'] ) { + if ( $status && ( true === $status['opcache_enabled'] || ! empty( $status['file_cache_only'] ) ) ) { $opcache_enabled = true; } }