Posted by mikeytown2 on August 2, 2012 at 6:33pm
11 followers
| Project: | Drupal core |
| Version: | 8.x-dev |
| Component: | menu system |
| Category: | task |
| Priority: | normal |
| Assigned: | Unassigned |
| Status: | needs review |
| Issue tags: | Performance |
Issue Summary
Drupal will load unnecessary entities (non-node) if a menu link to them is in the main menu. The reason I say it's loading them unnecessarily has to do with the fact that if a menu item is disabled it will still do an entity_load on it.
How to repo:
Standard Drupal Install
Create a new user
Link to user/2 in Main menu (admin/structure/menu/manage/main-menu)
Disable that link in the menu.
user/2 is still loaded on every page load even though that menu item is disabled.
Comments
#1
#2
The last submitted patch, drupal-1710656-1-skip-hidden-menu-items-D7.patch, failed testing.
#3
This patch should take care of the breadcrumb issue.
#4
menu_tree_check_access() on a logged out (anonymous) front page hit
Without Patch
cumulative time: 29ms
calls: 3
With Patch
cumulative time: 4.4ms
calls: 3
Results will vary depending on the site, but overall this should reduce the amount of code being ran.
#5
Patch for Drupal 8 attached below
#6
Patch for D6 after seeing this issue here http://drupal.stackexchange.com/questions/42232/ubercart-entries-in-menu...
Benchmark
Before: 22ms
After: 20ms
So a slight improvement on our site, but depending on the menu structure it could have a big improvement. I can verify that less code is being ran because the cachegrind file shrunk by 300kb with this patch.
#7
The Drupal 6 patch works a treat. Is it safe to apply in a live environment?
#8
The patch passed all D7 & D8 tests, so that's a good sign. My guess is it is safe to apply to D6 but I can't guarantee that its 100% safe.
#9
Yes Mike, it works. After apply in D7, I have also found some noticeable difference in profiling results.
#10
Subscribing. can anyone verify they tested drupal 6 no problems?
#11
I use the D6 patch on our production boxes. No issues have been reported.