From 24a96cd044047a1fddda4e02bda8aafc1c090226 Mon Sep 17 00:00:00 2001 From: Rolly Bueno Date: Mon, 14 Jul 2025 09:55:23 +0800 Subject: [PATCH 01/23] OPcache: Add information to the Site Health -> Server --- src/wp-admin/includes/class-wp-debug-data.php | 58 +++++++++++++++++++ 1 file changed, 58 insertions(+) diff --git a/src/wp-admin/includes/class-wp-debug-data.php b/src/wp-admin/includes/class-wp-debug-data.php index cd04297684bcd..06252cfc2eca0 100644 --- a/src/wp-admin/includes/class-wp-debug-data.php +++ b/src/wp-admin/includes/class-wp-debug-data.php @@ -471,6 +471,64 @@ private static function get_wp_server(): array { 'debug' => $imagick_loaded, ); + // OPCache. + $opcache_loaded = extension_loaded( 'opcache' ); + + $fields['opcache_availability'] = array( + 'label' => __( 'Is the OPcache extension available?' ), + 'value' => ( $opcache_loaded ? __( 'Yes' ) : __( 'No' ) ), + 'debug' => $opcache_loaded, + ); + + if ( $opcache_loaded && function_exists( 'opcache_get_status' ) ) { + $opcache_status = opcache_get_status( false ); + + if ( $opcache_status ) { + $fields['opcache_enabled'] = array( + 'label' => __( 'OPcache' ), + 'value' => ( $opcache_status['opcache_enabled'] ? __( 'Enabled' ) : __( 'Disabled' ) ), + 'debug' => $opcache_status['opcache_enabled'], + ); + + $fields['opcache_memory_usage'] = array( + 'label' => __( 'OPcache memory usage' ), + 'value' => sprintf( + /* translators: 1: Used memory, 2: Total memory */ + __( '%1$s of %2$s' ), + size_format( $opcache_status['memory_usage']['used_memory'] ), + size_format( $opcache_status['memory_usage']['free_memory'] + $opcache_status['memory_usage']['used_memory'] ) + ), + 'debug' => sprintf( + '%s of %s', + $opcache_status['memory_usage']['used_memory'], + $opcache_status['memory_usage']['free_memory'] + $opcache_status['memory_usage']['used_memory'] + ), + ); + + $fields['opcache_hit_rate'] = array( + 'label' => __( 'OPcache hit rate' ), + 'value' => sprintf( + /* translators: %s: Hit rate percentage */ + __( '%s%%' ), + round( $opcache_status['opcache_statistics']['opcache_hit_rate'], 2 ) + ), + 'debug' => $opcache_status['opcache_statistics']['opcache_hit_rate'], + ); + + $fields['opcache_cached_scripts'] = array( + 'label' => __( 'OPcache cached scripts' ), + 'value' => number_format_i18n( $opcache_status['opcache_statistics']['num_cached_scripts'] ), + 'debug' => $opcache_status['opcache_statistics']['num_cached_scripts'], + ); + + $fields['opcache_cached_keys'] = array( + 'label' => __( 'OPcache cached keys' ), + 'value' => number_format_i18n( $opcache_status['opcache_statistics']['num_cached_keys'] ), + 'debug' => $opcache_status['opcache_statistics']['num_cached_keys'], + ); + } + } + // Pretty permalinks. $pretty_permalinks_supported = got_url_rewrite(); From b53015801659d0b8cdccc98c98942125ba2b0b3f Mon Sep 17 00:00:00 2001 From: Rolly Bueno Date: Thu, 17 Jul 2025 17:37:04 +0800 Subject: [PATCH 02/23] Add Site HEalth test --- src/wp-admin/includes/class-wp-debug-data.php | 6 +-- .../includes/class-wp-site-health.php | 54 +++++++++++++++++++ 2 files changed, 57 insertions(+), 3 deletions(-) diff --git a/src/wp-admin/includes/class-wp-debug-data.php b/src/wp-admin/includes/class-wp-debug-data.php index 06252cfc2eca0..367e7de83bd29 100644 --- a/src/wp-admin/includes/class-wp-debug-data.php +++ b/src/wp-admin/includes/class-wp-debug-data.php @@ -471,8 +471,8 @@ private static function get_wp_server(): array { 'debug' => $imagick_loaded, ); - // OPCache. - $opcache_loaded = extension_loaded( 'opcache' ); + // Opcode Cache. + $opcache_loaded = extension_loaded( 'Zend OPcache' ); $fields['opcache_availability'] = array( 'label' => __( 'Is the OPcache extension available?' ), @@ -482,7 +482,7 @@ private static function get_wp_server(): array { if ( $opcache_loaded && function_exists( 'opcache_get_status' ) ) { $opcache_status = opcache_get_status( false ); - + if ( $opcache_status ) { $fields['opcache_enabled'] = array( 'label' => __( 'OPcache' ), diff --git a/src/wp-admin/includes/class-wp-site-health.php b/src/wp-admin/includes/class-wp-site-health.php index b7847d5e310a8..64ef8f25eadf6 100644 --- a/src/wp-admin/includes/class-wp-site-health.php +++ b/src/wp-admin/includes/class-wp-site-health.php @@ -2687,6 +2687,56 @@ public function get_test_autoloaded_options() { return $result; } + __( 'OPcache is enabled' ), + 'status' => 'good', + 'badge' => array( + 'label' => __( 'Performance' ), + 'color' => 'blue', + ), + 'description' => sprintf( + '

%s

', + __( 'OPcache improves PHP performance by storing precompiled script bytecode in memory, reducing the need for PHP to load and parse scripts on each request.' ) + ), + 'actions' => sprintf( + '

%s %s

', + 'https://www.php.net/manual/en/book.opcache.php', + __( 'Learn more about OPcache.' ), + /* translators: Hidden accessibility text. */ + __( '(opens in a new tab)' ) + ), + 'test' => 'opcache', + ); + + if ( $opcache_loaded ) { + $result['status'] = 'recommended'; + $result['label'] = __( 'OPcache is not available' ); + $result['description'] .= '

' . __( 'OPcache is not installed or enabled on your server. Enabling OPcache can significantly improve the performance of your site.' ) . '

'; + } elseif ( ! $opcache_enabled ) { + $result['status'] = 'recommended'; + $result['label'] = __( 'OPcache is installed but not enabled' ); + $result['description'] .= '

' . __( 'OPcache is installed but not enabled. Enabling OPcache can significantly improve the performance of your site.' ) . '

'; + } + + return $result; +} + /** * Returns a set of tests that belong to the site status page. * @@ -2775,6 +2825,10 @@ public static function get_tests() { 'label' => __( 'Autoloaded options' ), 'test' => 'autoloaded_options', ), + 'opcache' => array( + 'label' => __( 'OPcache' ), + 'test' => 'opcache', + ), ), 'async' => array( 'dotorg_communication' => array( From 231515b899b090dfca3d4e496523e2bcc15fdeb2 Mon Sep 17 00:00:00 2001 From: Rolly Bueno Date: Thu, 24 Jul 2025 09:58:33 +0800 Subject: [PATCH 03/23] Update: Remove scripts and keys + use functions_exists() for consistent check --- src/wp-admin/includes/class-wp-debug-data.php | 28 +------ .../includes/class-wp-site-health.php | 74 +++++++++---------- 2 files changed, 38 insertions(+), 64 deletions(-) diff --git a/src/wp-admin/includes/class-wp-debug-data.php b/src/wp-admin/includes/class-wp-debug-data.php index 367e7de83bd29..3dbc933707060 100644 --- a/src/wp-admin/includes/class-wp-debug-data.php +++ b/src/wp-admin/includes/class-wp-debug-data.php @@ -472,26 +472,18 @@ private static function get_wp_server(): array { ); // Opcode Cache. - $opcache_loaded = extension_loaded( 'Zend OPcache' ); - - $fields['opcache_availability'] = array( - 'label' => __( 'Is the OPcache extension available?' ), - 'value' => ( $opcache_loaded ? __( 'Yes' ) : __( 'No' ) ), - 'debug' => $opcache_loaded, - ); - - if ( $opcache_loaded && function_exists( 'opcache_get_status' ) ) { + if ( function_exists( 'opcache_get_status' ) ) { $opcache_status = opcache_get_status( false ); if ( $opcache_status ) { $fields['opcache_enabled'] = array( - 'label' => __( 'OPcache' ), + 'label' => __( 'Opcode cache' ), 'value' => ( $opcache_status['opcache_enabled'] ? __( 'Enabled' ) : __( 'Disabled' ) ), 'debug' => $opcache_status['opcache_enabled'], ); $fields['opcache_memory_usage'] = array( - 'label' => __( 'OPcache memory usage' ), + 'label' => __( 'Opcode cache memory usage' ), 'value' => sprintf( /* translators: 1: Used memory, 2: Total memory */ __( '%1$s of %2$s' ), @@ -506,7 +498,7 @@ private static function get_wp_server(): array { ); $fields['opcache_hit_rate'] = array( - 'label' => __( 'OPcache hit rate' ), + 'label' => __( 'Opcode cache hit rate' ), 'value' => sprintf( /* translators: %s: Hit rate percentage */ __( '%s%%' ), @@ -514,18 +506,6 @@ private static function get_wp_server(): array { ), 'debug' => $opcache_status['opcache_statistics']['opcache_hit_rate'], ); - - $fields['opcache_cached_scripts'] = array( - 'label' => __( 'OPcache cached scripts' ), - 'value' => number_format_i18n( $opcache_status['opcache_statistics']['num_cached_scripts'] ), - 'debug' => $opcache_status['opcache_statistics']['num_cached_scripts'], - ); - - $fields['opcache_cached_keys'] = array( - 'label' => __( 'OPcache cached keys' ), - 'value' => number_format_i18n( $opcache_status['opcache_statistics']['num_cached_keys'] ), - 'debug' => $opcache_status['opcache_statistics']['num_cached_keys'], - ); } } diff --git a/src/wp-admin/includes/class-wp-site-health.php b/src/wp-admin/includes/class-wp-site-health.php index 64ef8f25eadf6..d586ef79db965 100644 --- a/src/wp-admin/includes/class-wp-site-health.php +++ b/src/wp-admin/includes/class-wp-site-health.php @@ -2687,55 +2687,49 @@ public function get_test_autoloaded_options() { return $result; } - __( 'OPcache is enabled' ), - 'status' => 'good', - 'badge' => array( - 'label' => __( 'Performance' ), - 'color' => 'blue', - ), - 'description' => sprintf( - '

%s

', - __( 'OPcache improves PHP performance by storing precompiled script bytecode in memory, reducing the need for PHP to load and parse scripts on each request.' ) - ), - 'actions' => sprintf( - '

%s %s

', - 'https://www.php.net/manual/en/book.opcache.php', - __( 'Learn more about OPcache.' ), - /* translators: Hidden accessibility text. */ - __( '(opens in a new tab)' ) - ), - 'test' => 'opcache', - ); + $result = array( + 'label' => __( 'OPcache is enabled' ), + 'status' => 'good', + 'badge' => array( + 'label' => __( 'Performance' ), + 'color' => 'blue', + ), + 'description' => sprintf( + '

%s

', + __( 'OPcache improves PHP performance by storing precompiled script bytecode in memory, reducing the need for PHP to load and parse scripts on each request.' ) + ), + 'actions' => sprintf( + '

%s %s

', + 'https://www.php.net/manual/en/book.opcache.php', + __( 'Learn more about OPcache.' ), + /* translators: Hidden accessibility text. */ + __( '(opens in a new tab)' ) + ), + 'test' => 'opcache', + ); - if ( $opcache_loaded ) { - $result['status'] = 'recommended'; - $result['label'] = __( 'OPcache is not available' ); - $result['description'] .= '

' . __( 'OPcache is not installed or enabled on your server. Enabling OPcache can significantly improve the performance of your site.' ) . '

'; - } elseif ( ! $opcache_enabled ) { - $result['status'] = 'recommended'; - $result['label'] = __( 'OPcache is installed but not enabled' ); - $result['description'] .= '

' . __( 'OPcache is installed but not enabled. Enabling OPcache can significantly improve the performance of your site.' ) . '

'; - } + if ( ! $opcode_cache_enabled ) { + $result['status'] = 'recommended'; + $result['label'] = __( 'Opcode cache is not enabled' ); + $result['description'] .= '

' . __( 'OPcache is not enabled. Enabling OPcache can significantly improve the performance of your site.' ) . '

'; + } - return $result; -} + return $result; + } /** * Returns a set of tests that belong to the site status page. From 2ef962da82d4556ade90d1b2eca97c75fdd4f11c Mon Sep 17 00:00:00 2001 From: "Rolly G. Bueno Jr." <16076280+rollybueno@users.noreply.github.com> Date: Wed, 6 Aug 2025 08:48:40 +0800 Subject: [PATCH 04/23] Update src/wp-admin/includes/class-wp-site-health.php Co-authored-by: Weston Ruter --- src/wp-admin/includes/class-wp-site-health.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/wp-admin/includes/class-wp-site-health.php b/src/wp-admin/includes/class-wp-site-health.php index d586ef79db965..620e78162af54 100644 --- a/src/wp-admin/includes/class-wp-site-health.php +++ b/src/wp-admin/includes/class-wp-site-health.php @@ -2725,7 +2725,7 @@ public function get_test_opcache() { if ( ! $opcode_cache_enabled ) { $result['status'] = 'recommended'; $result['label'] = __( 'Opcode cache is not enabled' ); - $result['description'] .= '

' . __( 'OPcache is not enabled. Enabling OPcache can significantly improve the performance of your site.' ) . '

'; + $result['description'] .= '

' . __( 'Opcode cache is not enabled. Enabling this cache can significantly improve the performance of your site.' ) . '

'; } return $result; From 620c6872143100cc1b6f5a520ce5f6b0048f3048 Mon Sep 17 00:00:00 2001 From: "Rolly G. Bueno Jr." <16076280+rollybueno@users.noreply.github.com> Date: Wed, 6 Aug 2025 08:48:59 +0800 Subject: [PATCH 05/23] Update src/wp-admin/includes/class-wp-site-health.php Co-authored-by: Weston Ruter --- src/wp-admin/includes/class-wp-site-health.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/wp-admin/includes/class-wp-site-health.php b/src/wp-admin/includes/class-wp-site-health.php index 620e78162af54..f71e38977e74f 100644 --- a/src/wp-admin/includes/class-wp-site-health.php +++ b/src/wp-admin/includes/class-wp-site-health.php @@ -2821,7 +2821,7 @@ public static function get_tests() { ), 'opcache' => array( 'label' => __( 'OPcache' ), - 'test' => 'opcache', + 'test' => 'opcode_cache', ), ), 'async' => array( From e35fe8a143b76d9571293ce143b0f37fc080eed4 Mon Sep 17 00:00:00 2001 From: "Rolly G. Bueno Jr." <16076280+rollybueno@users.noreply.github.com> Date: Wed, 6 Aug 2025 08:49:38 +0800 Subject: [PATCH 06/23] Update src/wp-admin/includes/class-wp-site-health.php Co-authored-by: Weston Ruter --- src/wp-admin/includes/class-wp-site-health.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/wp-admin/includes/class-wp-site-health.php b/src/wp-admin/includes/class-wp-site-health.php index f71e38977e74f..257431a2edbdc 100644 --- a/src/wp-admin/includes/class-wp-site-health.php +++ b/src/wp-admin/includes/class-wp-site-health.php @@ -2690,7 +2690,7 @@ public function get_test_autoloaded_options() { /** * Tests if Opcode cache is enabled and available. * - * @since 6.7.0 + * @since 6.9.0 * * @return array The test result. */ From d546cb49d37440cbbb74e4fd7922ed90b703e7ac Mon Sep 17 00:00:00 2001 From: "Rolly G. Bueno Jr." <16076280+rollybueno@users.noreply.github.com> Date: Wed, 6 Aug 2025 08:50:05 +0800 Subject: [PATCH 07/23] Update src/wp-admin/includes/class-wp-debug-data.php Co-authored-by: Weston Ruter --- src/wp-admin/includes/class-wp-debug-data.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/wp-admin/includes/class-wp-debug-data.php b/src/wp-admin/includes/class-wp-debug-data.php index 3dbc933707060..5dcffd8d0fad7 100644 --- a/src/wp-admin/includes/class-wp-debug-data.php +++ b/src/wp-admin/includes/class-wp-debug-data.php @@ -478,7 +478,7 @@ private static function get_wp_server(): array { if ( $opcache_status ) { $fields['opcache_enabled'] = array( 'label' => __( 'Opcode cache' ), - 'value' => ( $opcache_status['opcache_enabled'] ? __( 'Enabled' ) : __( 'Disabled' ) ), + 'value' => ( $opcache_status['opcode_cache_enabled'] ? __( 'Enabled' ) : __( 'Disabled' ) ), 'debug' => $opcache_status['opcache_enabled'], ); From 1ea330c129c2cec918e281200733bb84c1e5588e Mon Sep 17 00:00:00 2001 From: "Rolly G. Bueno Jr." <16076280+rollybueno@users.noreply.github.com> Date: Wed, 6 Aug 2025 08:50:23 +0800 Subject: [PATCH 08/23] Update src/wp-admin/includes/class-wp-debug-data.php Co-authored-by: Weston Ruter --- src/wp-admin/includes/class-wp-debug-data.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/wp-admin/includes/class-wp-debug-data.php b/src/wp-admin/includes/class-wp-debug-data.php index 5dcffd8d0fad7..af4fa15783bea 100644 --- a/src/wp-admin/includes/class-wp-debug-data.php +++ b/src/wp-admin/includes/class-wp-debug-data.php @@ -476,7 +476,7 @@ private static function get_wp_server(): array { $opcache_status = opcache_get_status( false ); if ( $opcache_status ) { - $fields['opcache_enabled'] = array( + $fields['opcode_cache'] = array( 'label' => __( 'Opcode cache' ), 'value' => ( $opcache_status['opcode_cache_enabled'] ? __( 'Enabled' ) : __( 'Disabled' ) ), 'debug' => $opcache_status['opcache_enabled'], From 232ea6459e87f9005ae4c86e9fe67b4a68632a3a Mon Sep 17 00:00:00 2001 From: "Rolly G. Bueno Jr." <16076280+rollybueno@users.noreply.github.com> Date: Wed, 6 Aug 2025 08:50:41 +0800 Subject: [PATCH 09/23] Update src/wp-admin/includes/class-wp-site-health.php Co-authored-by: Weston Ruter --- src/wp-admin/includes/class-wp-site-health.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/wp-admin/includes/class-wp-site-health.php b/src/wp-admin/includes/class-wp-site-health.php index 257431a2edbdc..4409e8ce0c927 100644 --- a/src/wp-admin/includes/class-wp-site-health.php +++ b/src/wp-admin/includes/class-wp-site-health.php @@ -2702,7 +2702,7 @@ public function get_test_opcache() { } $result = array( - 'label' => __( 'OPcache is enabled' ), + 'label' => __( 'Opcode cache is enabled' ), 'status' => 'good', 'badge' => array( 'label' => __( 'Performance' ), From 152e81a99b0c9eec30e87eade7b74b73829dee9d Mon Sep 17 00:00:00 2001 From: "Rolly G. Bueno Jr." <16076280+rollybueno@users.noreply.github.com> Date: Wed, 6 Aug 2025 08:51:00 +0800 Subject: [PATCH 10/23] Update src/wp-admin/includes/class-wp-debug-data.php Co-authored-by: Weston Ruter --- src/wp-admin/includes/class-wp-debug-data.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/wp-admin/includes/class-wp-debug-data.php b/src/wp-admin/includes/class-wp-debug-data.php index af4fa15783bea..d8b27b4b711ab 100644 --- a/src/wp-admin/includes/class-wp-debug-data.php +++ b/src/wp-admin/includes/class-wp-debug-data.php @@ -497,7 +497,7 @@ private static function get_wp_server(): array { ), ); - $fields['opcache_hit_rate'] = array( + $fields['opcode_cache_hit_rate'] = array( 'label' => __( 'Opcode cache hit rate' ), 'value' => sprintf( /* translators: %s: Hit rate percentage */ From 63f41ea58f9689fabb409e2e523e0b4c502d8010 Mon Sep 17 00:00:00 2001 From: "Rolly G. Bueno Jr." <16076280+rollybueno@users.noreply.github.com> Date: Wed, 6 Aug 2025 08:51:24 +0800 Subject: [PATCH 11/23] Update src/wp-admin/includes/class-wp-site-health.php Co-authored-by: Weston Ruter --- src/wp-admin/includes/class-wp-site-health.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/wp-admin/includes/class-wp-site-health.php b/src/wp-admin/includes/class-wp-site-health.php index 4409e8ce0c927..d45e0bce56043 100644 --- a/src/wp-admin/includes/class-wp-site-health.php +++ b/src/wp-admin/includes/class-wp-site-health.php @@ -2688,7 +2688,7 @@ public function get_test_autoloaded_options() { } /** - * Tests if Opcode cache is enabled and available. + * Tests if opcode cache is enabled and available. * * @since 6.9.0 * From 923db6f8f28b98bce922fb69de93782f7fc55436 Mon Sep 17 00:00:00 2001 From: "Rolly G. Bueno Jr." <16076280+rollybueno@users.noreply.github.com> Date: Wed, 6 Aug 2025 08:51:48 +0800 Subject: [PATCH 12/23] Update src/wp-admin/includes/class-wp-site-health.php Co-authored-by: Weston Ruter --- src/wp-admin/includes/class-wp-site-health.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/wp-admin/includes/class-wp-site-health.php b/src/wp-admin/includes/class-wp-site-health.php index d45e0bce56043..6fb465e05f7e5 100644 --- a/src/wp-admin/includes/class-wp-site-health.php +++ b/src/wp-admin/includes/class-wp-site-health.php @@ -2694,7 +2694,7 @@ public function get_test_autoloaded_options() { * * @return array The test result. */ - public function get_test_opcache() { + public function get_test_opcode_cache() { $opcode_cache_enabled = false; if ( function_exists( 'opcache_get_status' ) ) { $status = opcache_get_status( false ); From 801cbee30b730925fbb3e713580f1164c0660e11 Mon Sep 17 00:00:00 2001 From: "Rolly G. Bueno Jr." <16076280+rollybueno@users.noreply.github.com> Date: Wed, 6 Aug 2025 08:52:01 +0800 Subject: [PATCH 13/23] Update src/wp-admin/includes/class-wp-site-health.php Co-authored-by: Weston Ruter --- src/wp-admin/includes/class-wp-site-health.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/wp-admin/includes/class-wp-site-health.php b/src/wp-admin/includes/class-wp-site-health.php index 6fb465e05f7e5..56925ee15ad29 100644 --- a/src/wp-admin/includes/class-wp-site-health.php +++ b/src/wp-admin/includes/class-wp-site-health.php @@ -2710,7 +2710,7 @@ public function get_test_opcode_cache() { ), 'description' => sprintf( '

%s

', - __( 'OPcache improves PHP performance by storing precompiled script bytecode in memory, reducing the need for PHP to load and parse scripts on each request.' ) + __( 'Opcode cache improves PHP performance by storing precompiled script bytecode in memory, reducing the need for PHP to load and parse scripts on each request.' ) ), 'actions' => sprintf( '

%s %s

', From 5ad77f963996c6db129fba838b76b8a95016d98f Mon Sep 17 00:00:00 2001 From: "Rolly G. Bueno Jr." <16076280+rollybueno@users.noreply.github.com> Date: Wed, 6 Aug 2025 08:52:46 +0800 Subject: [PATCH 14/23] Apply suggestions from code review Co-authored-by: Weston Ruter --- src/wp-admin/includes/class-wp-debug-data.php | 2 +- src/wp-admin/includes/class-wp-site-health.php | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/src/wp-admin/includes/class-wp-debug-data.php b/src/wp-admin/includes/class-wp-debug-data.php index d8b27b4b711ab..b267144fe41c2 100644 --- a/src/wp-admin/includes/class-wp-debug-data.php +++ b/src/wp-admin/includes/class-wp-debug-data.php @@ -482,7 +482,7 @@ private static function get_wp_server(): array { 'debug' => $opcache_status['opcache_enabled'], ); - $fields['opcache_memory_usage'] = array( + $fields['opcode_cache_memory_usage'] = array( 'label' => __( 'Opcode cache memory usage' ), 'value' => sprintf( /* translators: 1: Used memory, 2: Total memory */ diff --git a/src/wp-admin/includes/class-wp-site-health.php b/src/wp-admin/includes/class-wp-site-health.php index 56925ee15ad29..bd9e9523d0a31 100644 --- a/src/wp-admin/includes/class-wp-site-health.php +++ b/src/wp-admin/includes/class-wp-site-health.php @@ -2819,8 +2819,8 @@ public static function get_tests() { 'label' => __( 'Autoloaded options' ), 'test' => 'autoloaded_options', ), - 'opcache' => array( - 'label' => __( 'OPcache' ), + 'opcode_cache' => array( + 'label' => __( 'Opcode cache' ), 'test' => 'opcode_cache', ), ), From 3fd57b9eda3eb16edd7c8f42dd313b866ecfe53a Mon Sep 17 00:00:00 2001 From: Rolly Bueno Date: Wed, 6 Aug 2025 10:20:41 +0800 Subject: [PATCH 15/23] Site HEalth: Add default opcode item in server when disabled --- src/wp-admin/includes/class-wp-debug-data.php | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/src/wp-admin/includes/class-wp-debug-data.php b/src/wp-admin/includes/class-wp-debug-data.php index b267144fe41c2..6c6657412168f 100644 --- a/src/wp-admin/includes/class-wp-debug-data.php +++ b/src/wp-admin/includes/class-wp-debug-data.php @@ -478,7 +478,7 @@ private static function get_wp_server(): array { if ( $opcache_status ) { $fields['opcode_cache'] = array( 'label' => __( 'Opcode cache' ), - 'value' => ( $opcache_status['opcode_cache_enabled'] ? __( 'Enabled' ) : __( 'Disabled' ) ), + 'value' => ( $opcache_status['opcache_enabled'] ? __( 'Enabled' ) : __( 'Disabled' ) ), 'debug' => $opcache_status['opcache_enabled'], ); @@ -507,6 +507,12 @@ private static function get_wp_server(): array { 'debug' => $opcache_status['opcache_statistics']['opcache_hit_rate'], ); } + } else { + $fields['opcode_cache'] = array( + 'label' => __( 'Opcode cache' ), + 'value' => __( 'Disabled' ), + 'debug' => 'not available', + ); } // Pretty permalinks. From e62c774bf1d140b2971d4a7d8f229e7ea84750cc Mon Sep 17 00:00:00 2001 From: Rolly Bueno Date: Tue, 19 Aug 2025 19:48:24 +0800 Subject: [PATCH 16/23] Feedback: Silence call but add new logic to compensate --- src/wp-admin/includes/class-wp-debug-data.php | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/src/wp-admin/includes/class-wp-debug-data.php b/src/wp-admin/includes/class-wp-debug-data.php index 6c6657412168f..65df77068bc29 100644 --- a/src/wp-admin/includes/class-wp-debug-data.php +++ b/src/wp-admin/includes/class-wp-debug-data.php @@ -473,9 +473,15 @@ private static function get_wp_server(): array { // Opcode Cache. if ( function_exists( 'opcache_get_status' ) ) { - $opcache_status = opcache_get_status( false ); + $opcache_status = @opcache_get_status( false ); - if ( $opcache_status ) { + if ( false === $opcache_status ) { + $fields['opcode_cache'] = array( + 'label' => __( 'Opcode cache' ), + 'value' => __( 'Disabled by configuration' ), + 'debug' => 'not available', + ); + } else { $fields['opcode_cache'] = array( 'label' => __( 'Opcode cache' ), 'value' => ( $opcache_status['opcache_enabled'] ? __( 'Enabled' ) : __( 'Disabled' ) ), From 4a39b006b1a337f1e770dd6622909e923bc34a0c Mon Sep 17 00:00:00 2001 From: Rolly Bueno <16076280+rollybueno@users.noreply.github.com> Date: Wed, 21 Jan 2026 06:59:41 +0800 Subject: [PATCH 17/23] Apply suggestions from code review Co-authored-by: Weston Ruter --- src/wp-admin/includes/class-wp-debug-data.php | 2 +- src/wp-admin/includes/class-wp-site-health.php | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/src/wp-admin/includes/class-wp-debug-data.php b/src/wp-admin/includes/class-wp-debug-data.php index 7a059d5419aef..1ecd76ea5928f 100644 --- a/src/wp-admin/includes/class-wp-debug-data.php +++ b/src/wp-admin/includes/class-wp-debug-data.php @@ -473,7 +473,7 @@ private static function get_wp_server(): array { // Opcode Cache. if ( function_exists( 'opcache_get_status' ) ) { - $opcache_status = @opcache_get_status( false ); + $opcache_status = @opcache_get_status( false ); // phpcs:ignore WordPress.PHP.NoSilencedErrors.Discourage -- Warning emitted in failure case. if ( false === $opcache_status ) { $fields['opcode_cache'] = array( diff --git a/src/wp-admin/includes/class-wp-site-health.php b/src/wp-admin/includes/class-wp-site-health.php index 9918efc5398e1..2d39bf8719bc8 100644 --- a/src/wp-admin/includes/class-wp-site-health.php +++ b/src/wp-admin/includes/class-wp-site-health.php @@ -2758,7 +2758,7 @@ public function get_test_search_engine_visibility() { /** * Tests if opcode cache is enabled and available. * - * @since 6.9.0 + * @since 7.0.0 * * @return array The test result. */ From c3ef929e2d212dc77c40ab4664d6a37f4327ad43 Mon Sep 17 00:00:00 2001 From: Rolly Bueno <16076280+rollybueno@users.noreply.github.com> Date: Wed, 21 Jan 2026 07:23:30 +0800 Subject: [PATCH 18/23] Update src/wp-admin/includes/class-wp-site-health.php Co-authored-by: Weston Ruter --- src/wp-admin/includes/class-wp-site-health.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/wp-admin/includes/class-wp-site-health.php b/src/wp-admin/includes/class-wp-site-health.php index 2d39bf8719bc8..6af131a7fc3b0 100644 --- a/src/wp-admin/includes/class-wp-site-health.php +++ b/src/wp-admin/includes/class-wp-site-health.php @@ -2787,7 +2787,7 @@ public function get_test_opcode_cache() { /* translators: Hidden accessibility text. */ __( '(opens in a new tab)' ) ), - 'test' => 'opcache', + 'test' => 'opcache_cache', ); if ( ! $opcode_cache_enabled ) { From b8ee6437163149405182e8436f6328f8c0256075 Mon Sep 17 00:00:00 2001 From: Rolly Bueno Date: Wed, 21 Jan 2026 07:58:54 +0800 Subject: [PATCH 19/23] Improvement: Conditionally display additional info based on 'opcache_enabled' value --- src/wp-admin/includes/class-wp-debug-data.php | 48 ++++++++++--------- .../includes/class-wp-site-health.php | 20 ++++---- 2 files changed, 37 insertions(+), 31 deletions(-) diff --git a/src/wp-admin/includes/class-wp-debug-data.php b/src/wp-admin/includes/class-wp-debug-data.php index 1ecd76ea5928f..ac4963f63e528 100644 --- a/src/wp-admin/includes/class-wp-debug-data.php +++ b/src/wp-admin/includes/class-wp-debug-data.php @@ -488,30 +488,32 @@ private static function get_wp_server(): array { 'debug' => $opcache_status['opcache_enabled'], ); - $fields['opcode_cache_memory_usage'] = array( - 'label' => __( 'Opcode cache memory usage' ), - 'value' => sprintf( - /* translators: 1: Used memory, 2: Total memory */ - __( '%1$s of %2$s' ), - size_format( $opcache_status['memory_usage']['used_memory'] ), - size_format( $opcache_status['memory_usage']['free_memory'] + $opcache_status['memory_usage']['used_memory'] ) - ), - 'debug' => sprintf( - '%s of %s', - $opcache_status['memory_usage']['used_memory'], - $opcache_status['memory_usage']['free_memory'] + $opcache_status['memory_usage']['used_memory'] - ), - ); + if ( true === $opcache_status['opcache_enabled'] ) { + $fields['opcode_cache_memory_usage'] = array( + 'label' => __( 'Opcode cache memory usage' ), + 'value' => sprintf( + /* translators: 1: Used memory, 2: Total memory */ + __( '%1$s of %2$s' ), + size_format( $opcache_status['memory_usage']['used_memory'] ), + size_format( $opcache_status['memory_usage']['free_memory'] + $opcache_status['memory_usage']['used_memory'] ) + ), + 'debug' => sprintf( + '%s of %s', + $opcache_status['memory_usage']['used_memory'], + $opcache_status['memory_usage']['free_memory'] + $opcache_status['memory_usage']['used_memory'] + ), + ); - $fields['opcode_cache_hit_rate'] = array( - 'label' => __( 'Opcode cache hit rate' ), - 'value' => sprintf( - /* translators: %s: Hit rate percentage */ - __( '%s%%' ), - round( $opcache_status['opcache_statistics']['opcache_hit_rate'], 2 ) - ), - 'debug' => $opcache_status['opcache_statistics']['opcache_hit_rate'], - ); + $fields['opcode_cache_hit_rate'] = array( + 'label' => __( 'Opcode cache hit rate' ), + 'value' => sprintf( + /* translators: %s: Hit rate percentage */ + __( '%s%%' ), + round( $opcache_status['opcache_statistics']['opcache_hit_rate'], 2 ) + ), + 'debug' => $opcache_status['opcache_statistics']['opcache_hit_rate'], + ); + } } } else { $fields['opcode_cache'] = array( diff --git a/src/wp-admin/includes/class-wp-site-health.php b/src/wp-admin/includes/class-wp-site-health.php index 6af131a7fc3b0..88e69a20a54dd 100644 --- a/src/wp-admin/includes/class-wp-site-health.php +++ b/src/wp-admin/includes/class-wp-site-health.php @@ -2765,8 +2765,12 @@ public function get_test_search_engine_visibility() { public function get_test_opcode_cache() { $opcode_cache_enabled = false; if ( function_exists( 'opcache_get_status' ) ) { - $status = opcache_get_status( false ); - $opcode_cache_enabled = $status['opcache_enabled']; + $status = @opcache_get_status( false ); // phpcs:ignore WordPress.PHP.NoSilencedErrors.Discourage -- Warning emitted in failure case. + if ( $status ) { + if( true === $status['opcache_enabled'] ) { + $opcode_cache_enabled = true; + } + } } $result = array( @@ -3463,14 +3467,14 @@ public function get_page_cache_headers() { 'x-srcache-fetch-status' => $cache_hit_callback, // Generic caching proxies (Nginx, Varnish, etc.) - 'x-cache' => $cache_hit_callback, - 'x-cache-status' => $cache_hit_callback, - 'x-litespeed-cache' => $cache_hit_callback, - 'x-proxy-cache' => $cache_hit_callback, - 'via' => '', + 'x-cache' => $cache_hit_callback, + 'x-cache-status' => $cache_hit_callback, + 'x-litespeed-cache' => $cache_hit_callback, + 'x-proxy-cache' => $cache_hit_callback, + 'via' => '', // Cloudflare - 'cf-cache-status' => $cache_hit_callback, + 'cf-cache-status' => $cache_hit_callback, ); /** From dd325c431f0e3ea5f8a7d2f19d9736fccf54212c Mon Sep 17 00:00:00 2001 From: Rolly Bueno Date: Wed, 21 Jan 2026 07:59:28 +0800 Subject: [PATCH 20/23] Fix: Coding standard --- src/wp-admin/includes/class-wp-site-health.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/wp-admin/includes/class-wp-site-health.php b/src/wp-admin/includes/class-wp-site-health.php index 88e69a20a54dd..68cfdb18cabf1 100644 --- a/src/wp-admin/includes/class-wp-site-health.php +++ b/src/wp-admin/includes/class-wp-site-health.php @@ -2767,7 +2767,7 @@ public function get_test_opcode_cache() { if ( function_exists( 'opcache_get_status' ) ) { $status = @opcache_get_status( false ); // phpcs:ignore WordPress.PHP.NoSilencedErrors.Discourage -- Warning emitted in failure case. if ( $status ) { - if( true === $status['opcache_enabled'] ) { + if ( true === $status['opcache_enabled'] ) { $opcode_cache_enabled = true; } } From 0dae7c5ed24befe350e6af517ae68228ca4995c8 Mon Sep 17 00:00:00 2001 From: Rolly Bueno <16076280+rollybueno@users.noreply.github.com> Date: Wed, 21 Jan 2026 08:13:24 +0800 Subject: [PATCH 21/23] Apply suggestions from code review Co-authored-by: Weston Ruter --- src/wp-admin/includes/class-wp-debug-data.php | 2 +- src/wp-admin/includes/class-wp-site-health.php | 6 ++---- 2 files changed, 3 insertions(+), 5 deletions(-) diff --git a/src/wp-admin/includes/class-wp-debug-data.php b/src/wp-admin/includes/class-wp-debug-data.php index ac4963f63e528..55bf6449e8dad 100644 --- a/src/wp-admin/includes/class-wp-debug-data.php +++ b/src/wp-admin/includes/class-wp-debug-data.php @@ -484,7 +484,7 @@ private static function get_wp_server(): array { } else { $fields['opcode_cache'] = array( 'label' => __( 'Opcode cache' ), - 'value' => ( $opcache_status['opcache_enabled'] ? __( 'Enabled' ) : __( 'Disabled' ) ), + 'value' => $opcache_status['opcache_enabled'] ? __( 'Enabled' ) : __( 'Disabled' ), 'debug' => $opcache_status['opcache_enabled'], ); diff --git a/src/wp-admin/includes/class-wp-site-health.php b/src/wp-admin/includes/class-wp-site-health.php index 68cfdb18cabf1..c2318824ff996 100644 --- a/src/wp-admin/includes/class-wp-site-health.php +++ b/src/wp-admin/includes/class-wp-site-health.php @@ -2766,10 +2766,8 @@ public function get_test_opcode_cache() { $opcode_cache_enabled = false; if ( function_exists( 'opcache_get_status' ) ) { $status = @opcache_get_status( false ); // phpcs:ignore WordPress.PHP.NoSilencedErrors.Discourage -- Warning emitted in failure case. - if ( $status ) { - if ( true === $status['opcache_enabled'] ) { - $opcode_cache_enabled = true; - } + if ( $status && true === $status['opcache_enabled'] ) { + $opcode_cache_enabled = true; } } From 17e5a798ca2acdee872ea70398983bab9419f65b Mon Sep 17 00:00:00 2001 From: Rolly Bueno <16076280+rollybueno@users.noreply.github.com> Date: Sun, 25 Jan 2026 21:33:22 +0800 Subject: [PATCH 22/23] Apply suggestions from code review Co-authored-by: Weston Ruter Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com> --- src/wp-admin/includes/class-wp-debug-data.php | 2 +- src/wp-admin/includes/class-wp-site-health.php | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/src/wp-admin/includes/class-wp-debug-data.php b/src/wp-admin/includes/class-wp-debug-data.php index 55bf6449e8dad..e66b9535625e6 100644 --- a/src/wp-admin/includes/class-wp-debug-data.php +++ b/src/wp-admin/includes/class-wp-debug-data.php @@ -473,7 +473,7 @@ private static function get_wp_server(): array { // Opcode Cache. if ( function_exists( 'opcache_get_status' ) ) { - $opcache_status = @opcache_get_status( false ); // phpcs:ignore WordPress.PHP.NoSilencedErrors.Discourage -- Warning emitted in failure case. + $opcache_status = @opcache_get_status( false ); // phpcs:ignore WordPress.PHP.NoSilencedErrors.Discouraged -- Warning emitted in failure case. if ( false === $opcache_status ) { $fields['opcode_cache'] = array( diff --git a/src/wp-admin/includes/class-wp-site-health.php b/src/wp-admin/includes/class-wp-site-health.php index c2318824ff996..abc9298050d29 100644 --- a/src/wp-admin/includes/class-wp-site-health.php +++ b/src/wp-admin/includes/class-wp-site-health.php @@ -2760,7 +2760,7 @@ public function get_test_search_engine_visibility() { * * @since 7.0.0 * - * @return array The test result. + * @return array> The test result. */ public function get_test_opcode_cache() { $opcode_cache_enabled = false; @@ -2795,7 +2795,7 @@ public function get_test_opcode_cache() { if ( ! $opcode_cache_enabled ) { $result['status'] = 'recommended'; $result['label'] = __( 'Opcode cache is not enabled' ); - $result['description'] .= '

' . __( 'Opcode cache is not enabled. Enabling this cache can significantly improve the performance of your site.' ) . '

'; + $result['description'] .= '

' . __( 'Enabling this cache can significantly improve the performance of your site.' ) . '

'; } return $result; From 1e6815b1798eec791de6b344e9fb2cb0a3d8d341 Mon Sep 17 00:00:00 2001 From: Rolly Bueno <16076280+rollybueno@users.noreply.github.com> Date: Tue, 27 Jan 2026 08:53:07 +0800 Subject: [PATCH 23/23] Apply suggestions from code review Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com> --- src/wp-admin/includes/class-wp-site-health.php | 4 ++-- 1 file changed, 2 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 abc9298050d29..4e35d3a8b020b 100644 --- a/src/wp-admin/includes/class-wp-site-health.php +++ b/src/wp-admin/includes/class-wp-site-health.php @@ -2784,12 +2784,12 @@ public function get_test_opcode_cache() { ), 'actions' => sprintf( '

%s %s

', - 'https://www.php.net/manual/en/book.opcache.php', + esc_url( 'https://www.php.net/manual/en/book.opcache.php' ), __( 'Learn more about OPcache.' ), /* translators: Hidden accessibility text. */ __( '(opens in a new tab)' ) ), - 'test' => 'opcache_cache', + 'test' => 'opcode_cache', ); if ( ! $opcode_cache_enabled ) {