I installed Features on a large site and got time outs and memory limit errors when going to admin/structure/features/create
My memory limit is set to 256MB and the limit is 30 seconds.
After some hacking around I found that menu_links_features_export_options() was the culprit. If I returned this function before any of it's code ran I could get the page to load immediately.
I found that inside the function
menu_parent_options(menu_get_menus(), array('mlid' => 0));
was returning an array with a count of 2394 items. That's a lot of items to loop through in the following foreach.
I think there are a couple things that could be done here:
- hook_features_export_options() could have some kind of batching system to handle large results.
- There could be a UI to determine with components are even available for export.
- hook_features_api_alter() could be added to allow the removal of menu_links from the components array on a given site.
hook_features_api_alter() seems like the easiest to implement but it's a big API change. Is there another way around this problem?
Comment | File | Size | Author |
---|---|---|---|
#20 | 1153028-features-component-choice-6.x-1.patch | 6.77 KB | acbramley |
#15 | 1153028-component-choice-13.patch | 4.54 KB | mpotter |
#13 | 1153028-component-choice-12.patch | 4.54 KB | hefox |
#3 | 1153028-features-stop-menu-links.patch | 924 bytes | wiifm |
Comments
Comment #1
stevectorI am still having this problem and it makes the create/recreate page unusable.
Comment #2
wiifmHaving the same issue on our site, my timeout is set at 120 seconds, and yet it is still taking longer than this. Here is the resulting stacktrace:
Is there a cleaner way of disabling the menu_links feature export than simply commenting out parts of this file ?
Comment #3
wiifmOkay, have whipped up a solution that I feels helps everyone here - how about a hidden variable that will remove the menu_links from features?
Attached is a patch that implements this new feature. In order to use it, you can add in your settings.php file:
$conf['features_export_menu_links'] = FALSE;
I can now load the re-create screen for my features now in < 3 seconds (much better than 120 seconds and then timeout)
Comment #4
wiifmsetting review flag
Comment #5
mpotter CreditAttribution: mpotter commentedNo, that's not the right way to handle this.
Honestly, Menu Links have so many problems that I'm thinking they should be removed from Features entirely and maybe placed into their own module for people who really want them. Menu Links are *content* and Features is not about saving content to code (in my opinion). This is going to be a bigger and bigger issue with D8 with configuration management. I don't want to start an entire flame war about content vs configuration and how Features should handle it.
The Major problem with Menu Links is that Drupal does not use a unique ID for them. So multiple menu links with the same Title conflict and only a single one gets exported with Features. This also causes problems for multilingual menu links. Using UUIDs can help with this, but it's just another case for moving this out of core features.
I'd be interested in other opinions on moving Menu Links into a separate submodule. Then people can just disable the submodule rather than using a kludge config variable as proposed above.
Comment #6
tim.plunkettKill it, kill it with fire.
I'd say separate module, not submodule, if only because it'll give us usage stats.
Comment #7
hefox CreditAttribution: hefox commented+ to fire
Comment #8
stevector++ to taking menu links out of Features core. Use fire as necessary.
Comment #9
drupalninja99 CreditAttribution: drupalninja99 commented++ on taking menu links out - doesn't some other module handle this too? I know I have seen content_menu_links or something like that. So we can probably kill menu links.
Comment #10
drupalninja99 CreditAttribution: drupalninja99 commentedI don't know why we need the ajax thing at all. I wish it was server-side bc the ajax thing really bogs everything down
Comment #11
fringedgentian CreditAttribution: fringedgentian commentedThank you, the patch in #3 got the /recreate page appearing again for me when it was all memory timeouts before.
Comment #12
noorLight CreditAttribution: noorLight commentedThank you, patch #3 has put us back in business of using features again. Awesome work. Looking forward to this patch being implemented into features or some other resolution on how to handle large sites with a gazillion menu links. Just happy to have a fix and actually being able to use features again. Great work!
Comment #13
hefox CreditAttribution: hefox commentedI was having timeout issues with other components also, so expanded this patch to disable showing components on the feature create form and allow selection what menu to have as options
Needed to add a settings page for features, as currently doesn't have one as far as I can tell
Could move the code that adds the form to a hook that features.menu.inc implements
Comment #14
mpotter CreditAttribution: mpotter commentedSee if this requeues the test.
Comment #15
mpotter CreditAttribution: mpotter commentedSame patch, but adding it again to get the test to re-fire.
Comment #17
hefox CreditAttribution: hefox commented#15: 1153028-component-choice-13.patch queued for re-testing.
Comment #18
mpotter CreditAttribution: mpotter commentedWoot, finally passed the testbot. Good patch for handling sad modules that add 100+ variables or permissions. Someday would like to see some code to auto-detect components with more than 100 items and then use Ajax for the component fieldset expansion automatically.
But this is still a useful settings tab, so committed to 8e2a408.
Comment #20
acbramley CreditAttribution: acbramley commentedThis needs to be ported back to 6.x-1.x, this significantly sped things up for me when disabling menu links. I'm fairly sure I've got the mapping between the 7.x patch correct, just need clarification as it seems the forms are built quite differently between the 2 versions. This patch includes the menu entry, but if either this or #658772: Provide way to disable rebuild during features_flush_caches() get committed the patch for the other needs altering.
Comment #22
kenorb CreditAttribution: kenorb commentedMost likely backport to 6.x won't happen, therefore marking as fixed.