티스토리 수익 글 보기
{{ message }}
Fix TypeError in perflab_aao_query_autoloaded_options() by serializing non-scalar option values
#1934
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Summary
While running PHP 8.2.5, and visiting
/wp-admin/site-health.php, the following fatal error occurred in our instance:strlen(): Argument #1 ($string) must be of type string, array giventhis was triggered in
perflab_aao_query_autoloaded_options()wheneverwp_load_alloptions()returned an array or object, and the code calledstrlen()on that non-string, and since some object caching solutions can return unserialized data, it caused the fatal error above in PHP 8+Addresses #
this PR updates
perflab_aao_query_autoloaded_options()to wrap$option_valuewithmaybe_serialize()before measuring its length to make sure it’s always a valid stringRelevant technical choices
if the value is already a string, the function does nothing, if it’s an array or object, it gets validly serialized