Opened 94 minutes ago
#66834 new enhancement
Menus screen runs a postmeta query per item in the "add items" boxes
| Reported by: | arunjwilson | Owned by: | |
|---|---|---|---|
| Priority: | normal | Milestone: | Awaiting Review |
| Component: | Menus | Version: | trunk |
| Severity: | normal | Keywords: | |
| Cc: | Focuses: | performance |
Description
Walker_Nav_Menu_Checklist checks empty( $menu_item->label ) (wp-admin/includes/class-walker-nav-menu-checklist.php ~lines 97 and 106). For WP_Post items, WP_Post::__isset() (class-wp-post.php ~line 342) falls through to metadata_exists(), which queries postmeta for each item, because the box query (wp-admin/includes/nav-menu.php ~lines 433-434) sets update_post_meta_cache => false.
Measured on 7.1.5 (same code in trunk): 37 extra queries on the Menus screen of a small site; it grows with the number of posts/pages shown in the boxes.
Suggestion: only check ->label for non-WP_Post objects (it is never post meta), or prime the meta cache for the listed items in one query.
Related: #60199.