function admin_menu_toggle_modules in Administration menu 6
Same name and namespace in other branches
- 5.3 admin_menu.module \admin_menu_toggle_modules()
- 5.2 admin_menu.module \admin_menu_toggle_modules()
- 6.3 admin_menu.inc \admin_menu_toggle_modules()
Menu callback to enable/disable developer modules.
This saves up to 150ms on each uncached page request. Not much, but on larger Drupal sites this is actually a 10% performance increase.
1 string reference to 'admin_menu_toggle_modules'
- admin_menu_menu in ./
admin_menu.module - Implementation of hook_menu().
File
- ./
admin_menu.inc, line 469
Code
function admin_menu_toggle_modules() {
// URL token prtects this against CSRF attacks.
if (!isset($_GET['token']) || $_GET['token'] !== drupal_get_token($_GET['q'])) {
return MENU_ACCESS_DENIED;
}
$rebuild = FALSE;
$saved_state = variable_get('admin_menu_devel_modules_enabled', NULL);
if (isset($saved_state)) {
// Re-enable modules that were enabled before.
module_enable($saved_state);
variable_del('admin_menu_devel_modules_enabled');
drupal_set_message(t('Enabled these modules: !module-list.', array(
'!module-list' => implode(', ', $saved_state),
)));
$rebuild = TRUE;
}
else {
// Allow site admins to override this variable via settings.php.
$devel_modules = variable_get('admin_menu_devel_modules', array(
'cache_disable',
'coder',
'content_copy',
'debug',
'delete_all',
'demo',
'devel',
'devel_node_access',
'devel_themer',
'macro',
'form_controller',
'imagecache_ui',
'journal',
'trace',
'upgrade_status',
'user_display_ui',
'util',
'views_ui',
'views_theme_wizard',
));
// Store currently enabled modules in a variable.
$devel_modules = array_intersect(module_list(FALSE, FALSE), $devel_modules);
if (!empty($devel_modules)) {
variable_set('admin_menu_devel_modules_enabled', $devel_modules);
// Disable developer modules.
module_disable($devel_modules);
drupal_set_message(t('Disabled these modules: !module-list.', array(
'!module-list' => implode(', ', $devel_modules),
)));
$rebuild = TRUE;
}
else {
drupal_set_message(t('No developer modules are enabled.'));
}
}
if ($rebuild) {
// Make sure everything is rebuilt, basically a combination of the calls
// from system_modules() and system_modules_submit().
drupal_rebuild_theme_registry();
menu_rebuild();
cache_clear_all('schema', 'cache');
cache_clear_all();
drupal_clear_css_cache();
drupal_clear_js_cache();
// Synchronize to catch any actions that were added or removed.
actions_synchronize();
}
drupal_goto('');
}