Hi,
The module executes module_disable() and menu_rebuild() on every page load. that hurts performance on big sites.

Support from Acquia helps fund testing for Drupal Acquia logo

Comments

adel-by’s picture

Here's a patch that adds some controls to improve performance : execute module_disable, module_enable and menu_rebuild only if needed.
- enables modules only if they exists.
- disable modules only if there are still modules to disable.

azinck’s picture

Title: improvement » Using module to disable modules causes excessive calls to menu_rebuild()
Issue summary: View changes
Status: Active » Needs review
FileSize
1.54 KB

This behavior actually caused more than just bad performance for me. It caused some Views plugins not to be registered correctly and caused unpredictable behavior with Features. I've cleaned up the patch a bit here.

markpavlitski’s picture

Version: 7.x-1.3 » 7.x-1.x-dev
FileSize
1.75 KB
1.7 KB

This patch is based on #2, with some code style improvements.

I've removed the empty check in front of $modules = module_list() for readability and because it will have been rebuilt if any modules were enabled; module_list() is statically cached anyway, so won't affect performance if not.

I've also switched the foreach loop with array_diff to calculate which modules to enable, in line with the equivalent check when disabling modules.