Core: Ensure wp_using_ext_object_cache() always returns a boolean#11356
Core: Ensure wp_using_ext_object_cache() always returns a boolean#11356liaisontw wants to merge 2 commits intoWordPress:trunkfrom
Conversation
|
The following accounts have interacted with this PR and/or linked issues. I will continue to update these lists as activity occurs. You can also manually ask me to refresh this list by adding the Core Committers: Use this line as a base for the props when committing in SVN: To understand the WordPress project's expectations around crediting contributors, please review the Contributor Attribution page in the Core Handbook. |
Test using WordPress PlaygroundThe changes in this pull request can previewed and tested using a WordPress Playground instance. WordPress Playground is an experimental project that creates a full WordPress instance entirely within the browser. Some things to be aware of
For more details about these limitations and more, check out the Limitations page in the WordPress Playground documentation. |
0bdddbc to
334337a
Compare
Description
This PR addresses an inconsistency in the
wp_using_ext_object_cache()function where it could returnnullinstead of the documentedbooltype.In
src/wp-includes/load.php, the global variable$_wp_using_ext_object_cacheis used to determine if an external object cache is in use. However, if this function is called early in the WordPress loading hierarchy (before the global is initialized), it currently returnsnull.With the ongoing efforts to make WordPress more compatible with PHP 8.x strict typing, ensuring deterministic return types is critical to prevent
TypeErroror unexpected behavior in downstream logic.Key Changes:
$current_usingto(bool), we resolve the issue where an uninitialized global variable causes the function to leak anullvalue.Testing Instructions
wp_using_ext_object_cache()before the global variable is initialized (e.g., beforewp-settings.phpis fully loaded).NULL.bool(false).Trac ticket: https://core.trac.wordpress.org/ticket/64950
Use of AI Tools
AI assistance: Yes
Tool(s): Google Gemini
Model(s): Gemini 3 Flash
Used for: Authoring the technical description and formatting the testing instructions based on my code implementation. The code logic and testing methodology were reviewed and verified by me.
This Pull Request is for code review only. Please keep all other discussion in the Trac ticket. Do not merge this Pull Request. See GitHub Pull Requests for Code Review in the Core Handbook for more details.