3

I'm using a multi-site setup with Drupal 7.14 core, and I want to disable some modules within my sites/all/modules shared folder. One of them in particular is the File_Entity module.

Is there a way (drush, programmatically, bash script, etc) to check if another module (e.g. Views, custom CCK) is using it? drush pml | grep File Entity only let me see what is enabled or disabled, not if it is currently in use, or safe to remove.

2 Answers 2

4
drush pm-info mymodule|grep "Required by"

grep or don't grep is up to you ;)

Beware this does not list fields that require the module. This implies to views that use fields too.

fields: admin/reports/fields

views: admin/reports/fields/views-fields

those will list fields only, so if you have special pagers, formatters or something else that come from a module you will still have to search for them.

5
  • 1
    Yes, there can be dependencies in configuration as well as in code. For example if you create a view using a handler supplied by a module, then uninstall that module the view will break. Can be hard to track all these down. Commented Mar 13, 2013 at 17:21
  • As an example of a real stinker, suppose a module includes a template preprocess function that rearranges the content of certain variables. Your theme might depend on this having been done, but try tracking that down without code inspection! Commented Mar 13, 2013 at 17:24
  • hopefully those are listed as dependencies in the .info file for the actual module or theme (thats what that notice is for) if not you have a problem - but that mess is caused by bad style then. Commented Mar 13, 2013 at 17:25
  • 2
    Sure, that's what a developer /should/ do, but how many do when writing a custom theme for a single site? Considering how many times I've found SQL queries in template.php functions, that's a relatively minor offence :) Commented Mar 13, 2013 at 17:32
  • So, how can I achive similar result with Drush 9 ? Commented Jun 22, 2018 at 11:31
1

There is no drush pm-info command in Drush 9.3, it was replaced pm:list.

(https://github.com/drush-ops/drush/issues/3487, https://github.com/drush-ops/drush/issues/5557)

But now there is no Required by field in a field list
(see FIELDS section in drush pm:list --help)

Current workaround is just open /admin/modules page and look for Required by,
or use some php code if you have access to the drush.

drush ev '$module = "views"; $modules = _system_rebuild_module_data(); \Drupal::moduleHandler()->buildModuleDependencies($modules); var_dump($modules[$module]->required_by);'

UPD: Drupal 9 version:

# Dependencies of the module
drush ev '$module = "views"; $modules = \Drupal::service("extension.list.module")->getList(); echo implode(array_keys($modules[$module]->requires),", ");'
# Dependencies to the module
drush ev '$module = "views"; $modules = \Drupal::service("extension.list.module")->getList(); echo implode(array_keys($modules[$module]->required_by),", ");'

NOTE: be worried with php code, may cause performance issues.

2
  • This worked well, but I tweaked it a little to clean up the output. Editing above.
    – froboy
    Commented Nov 2, 2022 at 20:15
  • Thank you @froboy! I would add also ."\n" into echo statements. Commented Nov 6, 2022 at 16:23

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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