Taxonomy: Guard against non-object values in the terms cache. - #13204
Taxonomy: Guard against non-object values in the terms cache.#13204BogdanUngureanu wants to merge 3 commits into
Conversation
A truthy non-object in the `terms` cache group skipped the database lookup and fataled in `get_object_vars()`, taking down any `get_terms()` call that reached it. Fixes #65915.
|
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. |
|
Discovered as an issue in WooCommerce: woocommerce/woocommerce#67520 |
|
Another thing to note here: with PHP 8, This can be observed here: https://3v4l.org/8f1VN#v |
Validate if the taxonomy exists on the object to avoid a potential PHP Warning/notice and update the docblocks with PHPStan definitions Co-authored-by: Weston Ruter <westonruter@gmail.com>
|
Thanks @westonruter for the fast response. I've pushed a commit that updates the test. Let me know if more changes are needed. |
A truthy non-object in the
termscache group skipped the database lookup and fataled inget_object_vars(), taking down anyget_terms()call that reached it.This happens when the site uses a persistent cache (like redis) that fails to unserialize the object. In which case, it returns a string.
In this case, Core should check if the value returned from the cache can be properly used. If not, it should pull the term directly from the database.
Trac ticket: https://core.trac.wordpress.org/ticket/65915#ticket
Use of AI Tools
AI assistance: Yes
Tool(s): Claude Code
Model(s): Opus 4.8
Used for: Writing the test
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.