[wp-trac] [WordPress Trac] #22112: get_adjacent_post excluded_categories isn't excluded

WordPress Trac noreply at wordpress.org
Tue Sep 2 13:21:43 UTC 2014


#22112: get_adjacent_post excluded_categories isn't excluded
-------------------------------+-----------------------------
 Reporter:  PatNarciso         |       Owner:  wonderboymusic
     Type:  defect (bug)       |      Status:  reopened
 Priority:  normal             |   Milestone:  4.0
Component:  Posts, Post Types  |     Version:  3.8.1
 Severity:  normal             |  Resolution:
 Keywords:  has-patch          |     Focuses:  template
-------------------------------+-----------------------------
Changes (by pento):

 * keywords:  has-patch dev-feedback => has-patch


Comment:

 [attachment:22112.3.patch] is incorrect, it's failing the
 `test_get_adjacent_post_exclude_self_term` unit test.

 It's incorrect because `tt.term_id` is in `$term_array`, which can never
 contain items from `$excluded_terms`, so the `NOT IN` will always be true.

 The only way to exclude categories is with a subquery (as we currently
 have), or a LEFT JOIN, as demonstrated in [attachment:22112.4.patch]. This
 patch makes me sad, because it's harder to read than the subquery logic,
 and doesn't reduce the number of tables examined (so probably won't
 provide any performance benefits).

 Unless there are clear performance benefits to [attachment:22112.4.patch]
 (I didn't have time to benchmark it today), I'm fine with re-closing this
 ticket.

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


More information about the wp-trac mailing list