[wp-trac] [WordPress Trac] #33404: Customizer Menus: Search results can have duplicate items

WordPress Trac noreply at wordpress.org
Mon Nov 16 05:38:50 UTC 2015


#33404: Customizer Menus: Search results can have duplicate items
--------------------------+-----------------------------
 Reporter:  valendesigns  |       Owner:
     Type:  defect (bug)  |      Status:  assigned
 Priority:  normal        |   Milestone:  Future Release
Component:  Customize     |     Version:  4.3
 Severity:  normal        |  Resolution:
 Keywords:  needs-patch   |     Focuses:  administration
--------------------------+-----------------------------
Changes (by westonruter):

 * keywords:  has-patch needs-testing => needs-patch
 * owner:  westonruter =>
 * milestone:  4.4 => Future Release


Comment:

 I'm concerned about using `exclude` here when there are many terms in the
 database. If you paginate to high numbers, then the SQL query is going to
 get huge, and each `get_terms()` call will require a DB hit and wont be
 able to be pulled from `terms` cache like calls using just offsets can be.

 > The issue was the combination of `number` and `offset` when using
 `get_terms` that when the offset was higher than the number of terms would
 return all of the terms. I fixed this by passing an array of term IDs to
 exclude from the query and removing `offset`.

 @valendesigns So please confirm, is the problem in `get_terms()` is here
 specifically:

 {{{#!php
 <?php
         if ( $number && is_array( $terms ) && count( $terms ) > $number )
 {
                 $terms = array_slice( $terms, $offset, $number );
         }
 }}}

 And specifically the `count( $terms ) > $number` condition here is causing
 the problem here, where you would expect that if sending a high offset it
 would actually result in returning an empty `$terms` list, whereas right
 now it is returning all of the terms. unexpectedly.

 The condition here was added in [10416] as part of #8832. It seems that
 this patch perhaps is not doing the right thing.

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


More information about the wp-trac mailing list