Support for Drupal 7 is ending on 5 January 2025—it’s time to migrate to Drupal 10! Learn about the many benefits of Drupal 10 and find migration tools in our resource center.
Hi,
The module executes module_disable() and menu_rebuild() on every page load. that hurts performance on big sites.
Comment | File | Size | Author |
---|---|---|---|
#3 | interdiff.txt | 1.7 KB | markpavlitski |
#3 | environment_modules-excessive_menu_rebuilds-2103649-3.patch | 1.75 KB | markpavlitski |
#2 | environment_modules-excessive_menu_rebuilds-2103649-2.patch | 1.54 KB | azinck |
#1 | environment_modules-2103649.patch | 990 bytes | adel-by |
Comments
Comment #1
adel-by CreditAttribution: adel-by commentedHere'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.
Comment #2
azinck CreditAttribution: azinck commentedThis 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.
Comment #3
markpavlitski CreditAttribution: markpavlitski commentedThis 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.