Changeset 60661
- Timestamp:
- 08/26/2025 05:24:06 PM (3 months ago)
- Location:
- trunk
- Files:
-
- 2 edited
-
src/wp-includes/class-wp-term-query.php (modified) (1 diff)
-
tests/phpunit/tests/term/query.php (modified) (1 diff)
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/wp-includes/class-wp-term-query.php
r59325 r60661 850 850 foreach ( $children as $child_id ) { 851 851 $child = get_term( $child_id, $term->taxonomy ); 852 if ( $child->count ) { 852 853 if ( $child instanceof WP_Term && $child->count ) { 853 854 continue 2; 854 855 } -
trunk/tests/phpunit/tests/term/query.php
r57750 r60661 851 851 852 852 $this->assertSameSets( $expected, wp_list_pluck( $found, 'term_id' ) ); 853 } 854 855 /** 856 * Tests that a call to WP_Term_Query::get_terms() does not result in a PHP warning 857 * when get_term() returns null for a child term. 858 * 859 * The warning that we should not see: 860 * `Warning: Attempt to read property "count" on null`. 861 * 862 * @ticket 63877 863 */ 864 public function test_null_child_term_should_not_throw_warning() { 865 register_taxonomy( 866 'wptests_tax', 867 'post', 868 array( 869 'hierarchical' => true, 870 ) 871 ); 872 873 $t1 = self::factory()->term->create( 874 array( 875 'taxonomy' => 'wptests_tax', 876 ) 877 ); 878 879 $t2 = self::factory()->term->create( 880 array( 881 'taxonomy' => 'wptests_tax', 882 'parent' => $t1, 883 ) 884 ); 885 886 $this->term_id = $t2; 887 888 add_filter( 'get_term', array( $this, 'filter_term_to_null' ) ); 889 $q = new WP_Term_Query( 890 array( 891 'taxonomy' => 'wptests_tax', 892 'hide_empty' => true, 893 'fields' => 'ids', 894 ) 895 ); 896 remove_filter( 'get_term', array( $this, 'filter_term_to_null' ) ); 897 898 $this->assertIsArray( $q->terms, 'The result should be an array.' ); 899 $this->assertEmpty( $q->terms, 'The result should be empty.' ); 853 900 } 854 901
Note: See TracChangeset
for help on using the changeset viewer.