From e5935547d2faeaedb857f77f878c4d08d2b3389b Mon Sep 17 00:00:00 2001 From: Joe McGill Date: Tue, 4 Jun 2024 19:32:36 +0000 Subject: [PATCH] Site Health: Ensure each alloptions value is serialized. This adds additional hardening to the Autoload options Health Check to avoid potential bugs when extenders return unserialzed values from `wp_load_alloptions()`. Follow-up to [58332]. Props mukesh27, joemcgill, westonruter. Fixes #61276. git-svn-id: https://develop.svn.wordpress.org/trunk@58338 602fd350-edb4-49c9-b593-d223f7449a82 --- src/wp-admin/includes/class-wp-site-health.php | 7 +++++-- 1 file changed, 5 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 4fec62defa4cd..b4231e3f640fc 100644 --- a/src/wp-admin/includes/class-wp-site-health.php +++ b/src/wp-admin/includes/class-wp-site-health.php @@ -2598,8 +2598,11 @@ public function get_autoloaded_options_size() { $total_length = 0; - foreach ( $alloptions as $option_name => $option_value ) { - $total_length += strlen( $option_value ); + foreach ( $alloptions as $option_value ) { + if ( is_array( $option_value ) || is_object( $option_value ) ) { + $option_value = maybe_serialize( $option_value ); + } + $total_length += strlen( (string) $option_value ); } return $total_length;