From e6c2f66ab26a089d3aac0482519a06ee56d222e1 Mon Sep 17 00:00:00 2001 From: Sergey Biryukov Date: Mon, 17 Aug 2020 02:01:04 +0000 Subject: [PATCH] Site Health: Ensure that the tests returned by `WP_Site_Health::get_tests()` always have the required array keys: `direct` and `async`. This avoids PHP notices if these keys were accidentally removed using the `site_status_tests` filter. Props khag7, Ov3rfly, desrosj, Clorith. Fixes #50858. git-svn-id: https://develop.svn.wordpress.org/trunk@48808 602fd350-edb4-49c9-b593-d223f7449a82 --- src/wp-admin/includes/class-wp-site-health.php | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/src/wp-admin/includes/class-wp-site-health.php b/src/wp-admin/includes/class-wp-site-health.php index dd58d93b4e..de698d7a30 100644 --- a/src/wp-admin/includes/class-wp-site-health.php +++ b/src/wp-admin/includes/class-wp-site-health.php @@ -2207,6 +2207,15 @@ class WP_Site_Health { */ $tests = apply_filters( 'site_status_tests', $tests ); + // Ensure that the filtered tests contain the required array keys. + $tests = array_merge( + array( + 'direct' => array(), + 'async' => array(), + ), + $tests + ); + return $tests; }