We have had an issue with an expanding menu on a drupal 8 website that stops working when the command

drush cache-rebuild

is used.


When triggered, the error causes menus set to expand some sub-menu portion when active to stop expanding. That is to say the menu stops expanding at all, just stays in the inactive state.

The menus where this occurred were generated with the core menu module.

Logging into the site and using the clear all found in admin->config->performance->"clear all caches" fixes the issue.

Can anyone suggest an alternative drush/command line command we can use or how we can fix this problem?

drush clear-cache

does not seem to fix the issue.

I also tried executing as apache:

sudo -u www-data drush cache-rebuild

this also broke my menus.

What exactly is the difference between the UI cache clear and the drush one?


Ok after some digging - and please correct me if I am wrong here - it seems that when Drush rebuilds all caches it invokes:

drupal_rebuild(ClassLoader $class_loader, Request $request)

which is found in utility.inc, see drush github repo, while the admin command in Drupal calls:


found in common.inc, see drupal docs.

I have always been under the impression drush either called the same cache function as the internal performance button or at least they had the same behaviour, but they seem not to - at least in regards to my issue with the menu.

Can anyone suggest a way to have drush - or some other tool - invoke drupal_flush_all_caches()?

A further question, is the behaviour I am observing intended or should drush cache-rebuild work the same as drupal_flush_all_caches()?


Further experiments lead me to believe that it is specifically the clearing of the views cache that is causing some expanding menus to break.

drush cache-clear views

Will also trigger the behaviour. Again, clearing with the drupal_flush_all_caches() via the performance admin page fixes the issue.

  • 1
    It would help to know the drush version. – cilefen Jan 5 '17 at 1:57
  • What's not working? – Jaypan Jan 5 '17 at 3:03
  • Drush 8.1.0. Expanding manus are breaking. Simply put, they no longer expand. – tanbog Jan 5 '17 at 3:13

EDIT: I take it back. The problem has started again in drush 8.1.8 when Drush cr is used in a script - we have it in a back up script to reduce the size of the DB before pilling a copy of it - the application of the is-Active tag is getting broken on menu elements and any styling - say turning on or off visibility to expand the menu - seems to to totally break.

Manually clearing the cache through the UI fixes the issue but is not ideal

Drush 8.1.8 seems to have fixed the problem. I have looked through the change log though and cannot see what got changed in regards to the cache-rebuild that would fix the problem but it seems to have gone away so...


The following snippet works for me on Drupal 8.7

drush ev '\Drupal::service("router.builder")->rebuild();'

Not the answer you're looking for? Browse other questions tagged or ask your own question.