Certain Drush commands clear caches automatically, particularly project management - en, dis, etc.

I'd like to control that behaviour, per command, e.g.:

drush pm-disable --no-cc toolbar
drush pm-enable admin_menu quickbar admin_select

where the flag --no-cc means "don't clear caches after running this command". So caches would only be cleared after the second command, not the first (thus saving a number of seconds on large sites). You could even use --no-cc on all your commands and run a more selective drush cc registry; drush cc menu (for example) at the end. Obviously the user would have to be aware of the consequences.

I'm happy to start writing patches, but first I wonder if anyone else has thoughts on this?

Comments

moshe weitzman’s picture

FYI, you can pass in multiple modules to pm-disable and all the rest. When you do that, you only clear cache once. In general, I am not inclined to complicate things like this, but I'd look at a patch if one appears here.

pjcdawkins’s picture

Yes, although you can't disable modules and enable others in one command [edit: I mean, with only one cache clear]. Clearing caches all the time makes me impatient, so I will get a patch out. As for complexity, the defaults wouldn't change, and we already have optional flags like --resolve-dependencies and --skip. Perhaps, for pm-enable, the flags should be --skip-libraries and -skip-cache-clear, or --skip-lib and --skip-cc if you prefer.

jonhattan’s picture

There're other expensive operations that need to be done in addition to cache clearing whenever any of both commands is invoked.

As the use case isn't other than enabling and disabling modules at once as in admin/modules, I'd prefer to mimic apt-get, ie:

apt-get install foo bar- baz+
foo and baz are to be installed and bar to be removed.

apt-get remove foo bar+ baz-
foo and baz are to be removed and bar to be installed.

It needs a code refactoring and some tests but the code complexity doesn't seem to be much more than now (it will be similar to system_modules_submit()), and drush could go a step forward.

moshe weitzman’s picture

Title: Flag to prevent clearing caches for certain commands » Allow enable/disable of extensions within a single request
Priority: Normal » Minor

Seems exotic to me but if the code complexity is minimal then sure.

greg.1.anderson’s picture

Version: » 8.x-6.x-dev
Status: Active » Closed (won't fix)
Issue tags: +Needs migration

This issue was marked closed (won't fix) because Drush has moved to Github.

If this feature is still desired, you may copy it to our Github project. For best results, create a Pull Request that has been updated for the master branch. Post a link here to the PR, and please also change the status of this issue to closed (duplicate).

Please ask support questions on Drupal Answers.