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.
The code in hook_flush_caches() was run on every cron invocation on older D7 versions:
But even then re-building the menu router an be quite costly and if no theme has breakpoints there is no need to clear the menu cache.
diff --git a/sites/all/modules/contrib/breakpoints/breakpoints.module b/sites/all/modules/contrib/breakpoints/breakpoints
index 68e9ee0..e76fddc 100644
--- a/sites/all/modules/contrib/breakpoints/breakpoints.module
+++ b/sites/all/modules/contrib/breakpoints/breakpoints.module
@@ -59,6 +59,8 @@ function breakpoints_enable() {
* Do not use breakpoints_breakpoints_group_reload_from_theme as is clears the cache.
*/
function breakpoints_themes_enabled($theme_list) {
+ $menu_rebuild_needed = FALSE;
+
$themes = list_themes();
foreach ($theme_list as $theme_key) {
if (isset($themes[$theme_key]->info['breakpoints'])) {
@@ -97,9 +99,14 @@ function breakpoints_themes_enabled($theme_list) {
'!grouplink' => l(t('a new group is created'), 'admin/config/media/breakpoints/groups/' . $theme_key),
));
drupal_set_message($message, 'status');
+
+ $menu_rebuild_needed = TRUE;
}
}
- menu_rebuild();
+
+ if ($menu_rebuild_needed) {
+ variable_set('menu_rebuild_needed', TRUE);
+ }
}
/**
fixes the problem.
It is also a good idea to just set the variable instead of clearing the cache directly.
Comments
Comment #2
Fabianx CreditAttribution: Fabianx as a volunteer commentedComment #3
attiks CreditAttribution: attiks at Attiks commentedSomething similar is already in the dev branch
Comment #4
oadaeh CreditAttribution: oadaeh at Hook 42 commentedI think this can be closed, since the code is now in 7.x-1.6.