Skip to content

Commit

Permalink
Site Health: Ensure each alloptions value is serialized.
Browse files Browse the repository at this point in the history
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
  • Loading branch information
joemcgill committed Jun 4, 2024
1 parent c22d5c3 commit e593554
Showing 1 changed file with 5 additions and 2 deletions.
7 changes: 5 additions & 2 deletions src/wp-admin/includes/class-wp-site-health.php
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down

0 comments on commit e593554

Please sign in to comment.