WordPress.org

Make WordPress Core

Opened 19 months ago

Last modified 18 months ago

#36745 new enhancement

_wp_menu_item_classes_by_context

Reported by: spacedmonkey Owned by:
Milestone: Awaiting Review Priority: normal
Severity: normal Version: 3.0
Component: Menus Keywords: has-patch dev-feedback has-unit-tests
Focuses: performance Cc:

Description

_wp_menu_item_classes_by_context currently uses wp_get_object_terms. wp_get_object_terms has no caching in the function. get_the_terms function does have caching and should be used in this context.

Attachments (3)

test.patch (913 bytes) - added by spacedmonkey 19 months ago.
36745.patch (3.2 KB) - added by spacedmonkey 19 months ago.
36745.1.patch (3.6 KB) - added by spacedmonkey 18 months ago.

Download all attachments as: .zip

Change History (10)

@spacedmonkey
19 months ago

#1 @spacedmonkey
19 months ago

  • Keywords has-patch added

#2 @spacedmonkey
19 months ago

  • Type changed from enhancement to defect (bug)

I have changed this from enhancement to a bug. The fact that it doesn't use the caching function can be a massive performance issue, if there are lots of taxonomies and menu items. I believe this fix should go in the 4.5.2 release.

This ticket was mentioned in Slack in #core by spacedmonkey. View the logs.


19 months ago

#4 @spacedmonkey
19 months ago

  • Keywords dev-feedback has-unit-tests added
  • Type changed from defect (bug) to enhancement

Unit tests added. The unit tests should prove that the caching is working on single post pages.

#5 @spacedmonkey
19 months ago

Looking at this patch, a couple of line above it, it checks it is_taxonomy_hierarchical. It should really also check to see if the taxonomy is public. I can't think of a example where an underline would be needed for a non public taxonomy.

#6 @spacedmonkey
18 months ago

Added a new patch. This one adds a check to see that the taxonomy is public. This will decrease the number of calls to cache / db for none public taxonomies.

This ticket was mentioned in Slack in #core by spacedmonkey. View the logs.


18 months ago

Note: See TracTickets for help on using tickets.