[wp-trac] [WordPress Trac] #31724: Multiple calls get_terms() when: custom taxonomy (with no posts in it) and wp_nav_menu

WordPress Trac noreply at wordpress.org
Mon Mar 23 11:37:04 UTC 2015


#31724: Multiple calls get_terms() when: custom taxonomy (with no posts in it) and
wp_nav_menu
---------------------------------+-----------------------------
 Reporter:  kg69design           |       Owner:
     Type:  defect (bug)         |      Status:  new
 Priority:  normal               |   Milestone:  Future Release
Component:  General              |     Version:  4.1.1
 Severity:  normal               |  Resolution:
 Keywords:  has-patch 4.3-early  |     Focuses:  performance
---------------------------------+-----------------------------
Changes (by boonebgorges):

 * keywords:   => has-patch 4.3-early
 * milestone:  Awaiting Review => Future Release


Comment:

 Thanks for the additional info. The bit about child terms is critical to
 demonstrating the bug, and that wasn't mentioned the first time around.

 When a taxonomy term is included in a nav menu, `get_terms()` is called in
 `wp_get_nav_menu_items()` to prime the term cache for that term. If that
 taxonomy item happens to have children, and does not have any posts, then
 `get_terms()` will manually descend the term hierarchy to find 0-count
 terms. https://core.trac.wordpress.org/browser/tags/4.1.1/src/wp-
 includes/taxonomy.php?marks=1939,1941#L1938 This is important when you're
 trying to fetch a branch of the hierarchy tree, but it's not important in
 the case of nav menus. In fact, we shouldn't be traversing the tree at all
 when priming the nav menu cache - we only need to prime the cache for
 terms that are actually included in the nav menu.

 See [31724.diff]. Could you test this to make sure it's eliminating the
 additional queries for you? Let's do this first thing for 4.3.

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


More information about the wp-trac mailing list