-
Notifications
You must be signed in to change notification settings - Fork 3.2k
WP_Term_Query::get_terms() - fix warning #9596
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
WP_Term_Query::get_terms() - fix warning #9596
Conversation
https://core.trac.wordpress.org/ticket/63877 Need to check the return value from the call to `get_term()`.
|
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. |
|
While tests are having trouble passing now in |
|
I thought about tests before submitting this, but wasn't sure what form a test would take. For example, I could generate a test that fails when The inverse also seems not very helpful, if we test that we got class Tests_Term_Null_Term_Handling extends WP_UnitTestCase {
public function test_orphaned_hierarchy_causes_null_term_access() {
global $wpdb;
register_taxonomy( 'wptests_tax', 'post', array( 'hierarchical' => true ) );
$parent_term = self::factory()->term->create( array( 'taxonomy' => 'wptests_tax' ) );
$non_existent_child_id = 99999;
$hierarchy = array( $parent_term => array( $non_existent_child_id ) );
update_option( 'wptests_tax_children', $hierarchy );
$this->assertNull( get_term( $non_existent_child_id, 'wptests_tax' ), 'Non-existent term should return null' );
}
}If you are ok with a test like that, I'm happy to clean it up ( and add comments ) and add that to the patch. |
|
Yeah, I mean whatever scenario caused the error to happen in the first place on your site would be good to add a test for. |
|
I honestly don't know what happened, I noticed it on sites that have been running for more than 15 years and have probably been generating this warning for years. |
https://core.trac.wordpress.org/ticket/63877
Need to check the return value from the call to
get_term().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.