[wp-trac] [WordPress Trac] #47719: Consistency issue with `include` parameter set to "0" in `WP_Term_Query`

WordPress Trac noreply at wordpress.org
Sat Oct 31 21:57:47 UTC 2020


#47719: Consistency issue with `include` parameter set to "0" in `WP_Term_Query`
---------------------------------------------+-----------------------------
 Reporter:  audrasjb                         |       Owner:  SergeyBiryukov
     Type:  defect (bug)                     |      Status:  reviewing
 Priority:  normal                           |   Milestone:  5.6
Component:  Query                            |     Version:
 Severity:  normal                           |  Resolution:
 Keywords:  has-patch has-unit-tests commit  |     Focuses:
---------------------------------------------+-----------------------------
Changes (by hellofromTonya):

 * keywords:  dev-feedback has-patch has-unit-tests => has-patch has-unit-
     tests commit


Comment:

 [https://github.com/WordPress/wordpress-develop/pull/679 PR 679] adds unit
 for patch .

 **Step 1: Validate issue**

 Before applying patch
 [https://core.trac.wordpress.org/attachment/ticket/47719/47719.2.diff
 47719.2.diff], added the unit test. Confirmed the query returns all of the
 terms when `'include' => [0]`. Failing test results:

 {{{#!php
 <?php
 There was 1 failure:

 1) Tests_Term_Query::test_should_return_null_when_include_0
 Failed asserting that Array &0 (
     0 => WP_Term Object &000000003eeb693c000000003803654e (
         'term_id' => 2
         'name' => 'Term 0000018'
         'slug' => 'term-0000018'
         'term_group' => 0
         'term_taxonomy_id' => 2
         'taxonomy' => 'wptests_tax'
         'description' => 'Term description 0000018'
         'parent' => 0
         'count' => 0
         'filter' => 'raw'
     )
     1 => WP_Term Object &000000003eeb693d000000003803654e (
         'term_id' => 3
         'name' => 'Term 0000019'
         'slug' => 'term-0000019'
         'term_group' => 0
         'term_taxonomy_id' => 3
         'taxonomy' => 'wptests_tax'
         'description' => 'Term description 0000019'
         'parent' => 0
         'count' => 0
         'filter' => 'raw'
     )
     2 => WP_Term Object &000000003eeb693e000000003803654e (
         'term_id' => 4
         'name' => 'Term 0000020'
         'slug' => 'term-0000020'
         'term_group' => 0
         'term_taxonomy_id' => 4
         'taxonomy' => 'wptests_tax'
         'description' => 'Term description 0000020'
         'parent' => 0
         'count' => 0
         'filter' => 'raw'
     )
 ) is null.

 /var/www/tests/phpunit/tests/term/query.php:867
 }}}



 **Step 2: Apply patch. Revalidate.**

 Confirmed. Test passes, i.e. returns `null`.

 Marking for `commit`.

-- 
Ticket URL: <https://core.trac.wordpress.org/ticket/47719#comment:7>
WordPress Trac <https://core.trac.wordpress.org/>
WordPress publishing platform


More information about the wp-trac mailing list