Problem/Motivation

Much like we force dependent modules to be enabled, it would be handy to be able to disable a module and its dependencies recursively. When there are several dependencies between modules, several successive rounds of disabling modules are required which takes a really considerable amount of time and makes the whole procedure tedious.

Proposed resolution

These two options are discussed:

A. Use Javascript to:

1) when a user clicks on a checked-disabled check box, enable and uncheck it, then recursively uncheck all modules which depend on that module and then all modules which depend on the modules which were just unchecked, etc. Could also display a popup message informing the user that unchecking this module will cause the following modules to be unchecked as well.

and/or

2) when a user unchecks a module, check if there are any modules which it requires and enable their check box, if possible.

B. Don't disable any check boxes on the form, and then when the form gets submitted, check if there are any additional modules which will need to be disabled and then ask the user if they would like to continue. Similar process to enabling module dependencies.

Remaining tasks

After enough discussion, the general consensus is to try and have as much consistency with the way things are done now when enabling modules that have dependencies. So we need to go with option B mentioned above where basically, when you click submit, Drupal would now tell you two things and get you to confirm that the following modules will be enabled and disabled:

1) List of modules which will now be enabled because they are dependencies for modules you want to enable.

2) List of modules which will now be disabled because 1 or more of the modules they depend on are being disabled.

Latest patch available for testing is in comment #21 below.

#107038: Javascript to select module dependencies

User interface changes

Any module can be selected to be disabled on the modules page (besides the always required core modules such as node and user). After submitting the page a confirmation is required to disable possible dependant modules.

API changes

none.

Original report by NancyDru

// Text of original report:

Much like we force dependent modules to be enabled, it would be might handy to be able to disable a module and its dependencies. I just went to disable Update (in this case, but it's not important which one) because of a problem I'm debugging and there were two levels of dependencies that meant I had to disable 3 times - way too much overhead.

Support from Acquia helps fund testing for Drupal Acquia logo

Comments

Anonymous’s picture

The two options I can think of are

A. Use Javascript to:
1) when a user clicks on a checked-disabled check box, enable and uncheck it, then recursively uncheck all modules which depend on that module and then all modules which depend on the modules which were just unchecked, etc. Could also display a popup message informing the user that unchecking this module will cause the following modules to be unchecked as well.

and/or

2) when a user unchecks a module, check if there are any modules which it requires and enable their check box, if possible.

B. Don't disable any check boxes on the form, and then when the form gets submitted, check if there are any additional modules which will need to be disabled and then ask the user if they would like to continue. Similar process to enabling module dependencies.

...Thoughts?

authentictech’s picture

I agree that this issue needs to be addressed and that the solution is to use Javascript to enable or disable checkboxes according to whether dependant modules are enabled/disabled

This is also similar to a feature request I was going to make now so I will post it here instead as it can probably be implemented while solving this one.

When updating modules the process usually involves disabling all non-core modules. When there are several dependencies between modules this will involve several rounds of disabling modules. The last time I did this it required 4 rounds of disabling modules which took a total time of approx. 3–4 minutes to complete. This is much too long, particularly as we want to encourage people to update modules/core regularly and as soon as possible, and it is unnecessary...

I suggest making the update process much easier by placing a button at the top of the module page with the button text saying, "Disable all contributed modules". When clicked, all but the presently enabled core modules will be disabled. This addition would greatly increase the speed of the update process and usability.

--

Edit: decided to post my latter suggestion as a new issue #490274: One-click button to disable all contributed modules so it doesn't get overlooked.

NancyDru’s picture

@authentictech: I'm going to guess you don't do many multi-sites. I have as many as 12 sites on a single code base, so there are 12 different combinations of contribs that would have to be written down before disabling everything. I'm sorry, but disabling all contribs just is not a viable option for me. For me to disable A, which is used by B, which is used by C, all I want is to be able to disable A, B, and C the same time. I don't want any others disabled.

authentictech’s picture

@authentictech: I'm going to guess you don't do many multi-sites.

Wow. Were you intending to sound so snotty? (If not, it's not always so easy to tell in forums). You don't need to make such guesses. It's quite natural, whatever sites a person works with, to assume that someone is working on a single installation site unless they have otherwise stated.

I have as many as 12 sites on a single code base ... disabling all contribs just is not a viable option for me

Now you've clarified your situation, I can see my suggestion was addressing with a slightly different problem. Please everyone ignore my earlier post which is being dealt with in a different queue. Thank you.

NancyDru’s picture

No, I was not being snotty; sorry that it sounded that way. I just wanted to point out that your solution would present a major headache to those of us who have a bunch of modules that are not in use on that particular site. If I find a particular module is used on only one site, it goes in sites/sitename/modules. But if it is used by several sites, it goes in sites/all/modules, which makes it show up to all sites, even if it is not being used on a particular one.

Anonymous’s picture

So would anyone like to give me some feedback?

My preference would be to go with option B which I mentioned above, because it is similar to the process when Drupal tells you additional modules need to be enabled.

So basically, when you click submit, Drupal would now tell you two things and get you to confirm that the following modules will be enabled and disabled:

1) List of modules which will now be enabled because they are dependencies for modules you want to enable.

2) List of modules which will now be disabled because 1 or more of the modules they depend on are being disabled.

I am more than happy to write a patch for this feature, but I would like to get some feedback first and know if people are interested or not. So please let me know what you think. Just a simple "I think this will be/won't be useful" comment would be helpful, thanks!

NancyDru’s picture

Yes, I like the consistency. How do you get around the disabling of the check box on the depended-upon modules?

Anonymous’s picture

I haven't looked at the code yet, but I'm sure it can't be too hard to remove the code for core which disables the check boxes on the modules page, so the users are free to uncheck anything they like. Except for core modules :-)

The only downside is, users would need to pay attending to what they are unchecking so they they don't get a big surprise on the next page when Drupal tells them that additional modules need to be disabled and asks them to confirm.

Maybe we could also look at adding cues to the depended-upon modules to make them stand out.

Pancho’s picture

Version: 7.x-dev » 8.x-dev

moving to Drupal 8 queue

lpalgarvio’s picture

NancyDru’s picture

And would such a solution degrade gracefully?

lpalgarvio’s picture

i have no clue. just noting a similar issue :)

klausi’s picture

Status: Active » Needs review
FileSize
3.99 KB

Here is a patch that allows users to disable any module (except the required core modules). If the module has dependants then the confirmation form suggests to disable them as well. Needs some testing.

klausi’s picture

Fixed plural message for disabling multiple modules.

klausi’s picture

Now with a test case :-)

klonos’s picture

Title: Disable module with dependencies » Allow disabling of modules with dependencies (by recursively disabling their dependencies too)

...less vague issue title (if you guys don't mind) and subscribing too.

I'll go through the issue and update it's issue summary according to Issue summary standards. Someone with more knowledge please update the "API changes" and other sections too as required. Thanx.

PS: ...talking about API changes, if there are none I mean, could D7 possibly benefit from this too?

klonos’s picture

...done. Please update it as you see fit.

klonos’s picture

Issue summary: View changes

...compliance to issue summary template ;)

klausi’s picture

Great, I see no API changes here. Updated the issue summary.

klonos’s picture

Thanx for taking the time to reply and update the summary Klaus! No API change is great news, because we have more chances to get this backported to D7 ;)

NancyDru’s picture

Adding tags

klausi’s picture

Patch does not apply anymore. Here is a new patch with an additional test case for the disable ordering.

klausi’s picture

Issue summary: View changes

updated ui changes & api changes

klonos’s picture

...updated link to latest patch in issue summary to point to #21 ;)

Can someone suggest a couple of contrib projects with multiple dependencies and multiple levels of dependencies too (IOW modules that depend on others that in turn depend on more)? Thanx.

NancyDru’s picture

Well, Calendar springs to mind. Depends on Date, which has its own dependencies.

Oh, yes, Media Gallery has lots of dependencies.

sun’s picture

Major issues:

  1. Dependent modules have to be disabled first. Because they rely on the functionality provided by modules they require.
  2. Drupal's hook system is based on the mere existence of functions. Hence, when disabling multiple, interdependent modules at the same time, arbitrary and unintended hook implementations are invoked.
  3. It would be utterly wrong to automatically disable dependencies. At maximum, there could only be a belated intermediate/confirmation form (after disabling the dependent module(s)) that asks the user whether she also wants to disable the required modules (and of course, only suggesting modules that are not required by other enabled modules).

See also:
#1029606: Regression: Not loading the .module file causes a fatal error when uninstalling some modules (as does loading it)
#151452: Uninstalling modules does not follow dependencies and can lead to WSOD
#592800: Dependent modules are still installed when required modules return errors in hook_requirements('install')

The JavaScript suggestion in this issue seems to be a duplicate of #107038: Javascript to select module dependencies

klausi’s picture

Title: Allow disabling of modules with dependencies (by recursively disabling their dependencies too) » Allow disabling of modules with dependents (by recursively disabling their dependents first)

1. Yes, they are disabled first with this patch.
2. Uhm ... not sure what you mean. Yes, we should take care of the ordering when disabling modules. Can you give me an example where this approach could fail?
3. This patch is not about disabling dependencies automatically. It is about disabling dependents. Updated the issue title, sorry for that ambiguity.

NancyDru’s picture

Title: Allow disabling of modules with dependents (by recursively disabling their dependents first) » Allow disabling of modules with dependencies (by recursively disabling their dependencies too)

Sun, I could live with a form that steps me through it (similar to the update.php process). The fact is that the module admin page is probably the consistently slowest page in Drupal and having to load and save it several times is extremely error prone, time consuming, and aggravating.

NancyDru’s picture

Title: Allow disabling of modules with dependencies (by recursively disabling their dependencies too) » Allow disabling of modules with dependents (by recursively disabling their dependents first)

Setting title back

sun’s picture

Alright, thanks, now I understand. Not backportable, so removing tags.

Overall, this idea makes sense to me. However:

You can try to implement this, but this will require excessive tests. I'm not sure whether all edge-cases are covered by existing modules in core, so it's possible that we have to add some hidden testing modules that depend on each other, and which additionally implement some advanced hooks; e.g., hook_disable(), hook_modules_disabled(), hook_system_info_alter(), containing direct calls to functions in the required/parent modules, and ideally also a registered and auto-loaded class including override (extended class in a dependent module).

FYI: Everyone is aware that the process of disabling and uninstalling modules is time-consuming and cumbersome, but as of now, it's the only way to ensure that modules are processed in the correct order, and more importantly, that hook implementations are processed in the correct order and no implementations are invoked that shouldn't be invoked. In other words: Cumbersome is better than fatal errors and WSODs.

klonos’s picture

Who said that we'll accept and implement an idea that is *proven* to give fatals and WSODs? The goal is to correct the current cumbersomeness + have a solid solution. I am pretty confident we'll figure a way eventually. Fear of *possible* errors and WSODs shouldn't be a reason to stop working on improving things. The same goes for fear of excessive work and thus sticking with the old ways instead.

So, yes, lets have as many tests as required to have QA but lets fix this.

PS: I was under the impression that only API changes held back backporting. Does the same thing stand for any important UI changes too?

klausi’s picture

Status: Needs review » Needs work

@sun: the patch already has test cases that cover the general dependency chain. Modules are ordered correctly when they are disabled.

Why do I have to write excessive tests to get this approved? Yes, I can imagine that there could be edge cases that might lead to unintended behavior. But that applies to any new feature that enters Drupal core.

Let's get to the details:

  • hook_disable(): This is called when the module itself is disabled. It is not called if another module is disabled. Why should I test for that?
  • hook_modules_disabled(): Might be interesting whether this hook is still called in a previously disabled module.
  • hook_system_info_alter(): same here, but that would apply to any hook then. Could you give an example why we should exactly test for this one?
  • registered and auto-loaded class: why? The module was disabled and no code in it what so ever should be executed, so why should we test for that?

So I can see only one interesting additional test case on hook_modules_disabled(), but that's it. Marking as "needs work" until we have that test.

klausi’s picture

Status: Needs work » Needs review
FileSize
9.61 KB

New test case added that checks hook_modules_disabled() on disabled modules. Added yet another test module for that (disable_test). Everything works as expected.

@sun: is that enough or can you come up with another case that would fail?

Status: Needs review » Needs work

The last submitted patch, 468208-module-disable-dependants.patch, failed testing.

klausi’s picture

Status: Needs work » Needs review

Testbot seems to be broken, re-test later.

xjm’s picture

Status: Needs review » Needs work
Issue tags: +Novice

Tagging as novice for the task of rerolling the Drupal 8.x patch on account of #22336: Move all core Drupal files under a /core folder to improve usability and upgrades.

If you need help rerolling this patch, you can come to core office hours or ask in #drupal-gitsupport on IRC.

klausi’s picture

Status: Needs work » Needs review
Issue tags: -Novice
FileSize
8.48 KB

Reroll.

Status: Needs review » Needs work

The last submitted patch, 468208-module-disable-dependants.patch, failed testing.

xjm’s picture

That's a legitimate fail, so it looks like the patch needs work yet.

Niklas Fiekas’s picture

Doesn't apply against HEAD, so here's a reroll.

Edge case: Say you have Comment module enabled, Forum disabled. Now untick Comment, tick Forum. Current message: "You must disable the Forum module to disable Comment."
That message looks fine, actually. So just to make it sure: Should the message be like that? Will Forum module disabling hooks be fired, although it was never enabled?

Niklas Fiekas’s picture

Status: Needs work » Needs review
FileSize
8.07 KB

Meh ... wrong diff.

Status: Needs review » Needs work

The last submitted patch, 468208-module-disable-dependants-39.patch, failed testing.

klonos’s picture

Title: Allow disabling of modules with dependents (by recursively disabling their dependents first) » Allow uninstalling of modules with dependents (by offering to recursively uninstall their dependents as well)
klonos’s picture

Title: Allow uninstalling of modules with dependents (by offering to recursively uninstall their dependents as well) » Allow uninstalling modules with dependents by offering to recursively uninstall their dependents as well.

...

klonos’s picture

Issue summary: View changes

updated link to latest patch ;)

kattekrab’s picture

Can this still go in given we're now in Beta? I was just doing some testing and hit the uninstall page - and found this help text

"The following reason prevents Block from being uninstalled: Required by: Custom Block"

That doesn't seem very user friendly to me, and could probably be phrased better...
perhaps "Custom Block requires this module to be installed. It can not be uninstalled."
or "This module can not be uninstalled because it is required by Custom Block. "

Then I found this issue - which would require different language again.

Version: 8.0.x-dev » 8.1.x-dev

Drupal 8.0.6 was released on April 6 and is the final bugfix release for the Drupal 8.0.x series. Drupal 8.0.x will not receive any further development aside from security fixes. Drupal 8.1.0-rc1 is now available and sites should prepare to update to 8.1.0.

Bug reports should be targeted against the 8.1.x-dev branch from now on, and new development or disruptive changes should be targeted against the 8.2.x-dev branch. For more information see the Drupal 8 minor version schedule and the Allowed changes during the Drupal 8 release cycle.

Version: 8.1.x-dev » 8.2.x-dev

Drupal 8.1.9 was released on September 7 and is the final bugfix release for the Drupal 8.1.x series. Drupal 8.1.x will not receive any further development aside from security fixes. Drupal 8.2.0-rc1 is now available and sites should prepare to upgrade to 8.2.0.

Bug reports should be targeted against the 8.2.x-dev branch from now on, and new development or disruptive changes should be targeted against the 8.3.x-dev branch. For more information see the Drupal 8 minor version schedule and the Allowed changes during the Drupal 8 release cycle.

Version: 8.2.x-dev » 8.3.x-dev

Drupal 8.2.6 was released on February 1, 2017 and is the final full bugfix release for the Drupal 8.2.x series. Drupal 8.2.x will not receive any further development aside from critical and security fixes. Sites should prepare to update to 8.3.0 on April 5, 2017. (Drupal 8.3.0-alpha1 is available for testing.)

Bug reports should be targeted against the 8.3.x-dev branch from now on, and new development or disruptive changes should be targeted against the 8.4.x-dev branch. For more information see the Drupal 8 minor version schedule and the Allowed changes during the Drupal 8 release cycle.

Version: 8.3.x-dev » 8.4.x-dev

Drupal 8.3.6 was released on August 2, 2017 and is the final full bugfix release for the Drupal 8.3.x series. Drupal 8.3.x will not receive any further development aside from critical and security fixes. Sites should prepare to update to 8.4.0 on October 4, 2017. (Drupal 8.4.0-alpha1 is available for testing.)

Bug reports should be targeted against the 8.4.x-dev branch from now on, and new development or disruptive changes should be targeted against the 8.5.x-dev branch. For more information see the Drupal 8 minor version schedule and the Allowed changes during the Drupal 8 release cycle.

Version: 8.4.x-dev » 8.5.x-dev

Drupal 8.4.4 was released on January 3, 2018 and is the final full bugfix release for the Drupal 8.4.x series. Drupal 8.4.x will not receive any further development aside from critical and security fixes. Sites should prepare to update to 8.5.0 on March 7, 2018. (Drupal 8.5.0-alpha1 is available for testing.)

Bug reports should be targeted against the 8.5.x-dev branch from now on, and new development or disruptive changes should be targeted against the 8.6.x-dev branch. For more information see the Drupal 8 minor version schedule and the Allowed changes during the Drupal 8 release cycle.

Version: 8.5.x-dev » 8.6.x-dev

Drupal 8.5.6 was released on August 1, 2018 and is the final bugfix release for the Drupal 8.5.x series. Drupal 8.5.x will not receive any further development aside from security fixes. Sites should prepare to update to 8.6.0 on September 5, 2018. (Drupal 8.6.0-rc1 is available for testing.)

Bug reports should be targeted against the 8.6.x-dev branch from now on, and new development or disruptive changes should be targeted against the 8.7.x-dev branch. For more information see the Drupal 8 minor version schedule and the Allowed changes during the Drupal 8 release cycle.

Version: 8.6.x-dev » 8.8.x-dev

Drupal 8.6.x will not receive any further development aside from security fixes. Bug reports should be targeted against the 8.8.x-dev branch from now on, and new development or disruptive changes should be targeted against the 8.9.x-dev branch. For more information see the Drupal 8 and 9 minor version schedule and the Allowed changes during the Drupal 8 and 9 release cycles.

Version: 8.8.x-dev » 8.9.x-dev

Drupal 8.8.7 was released on June 3, 2020 and is the final full bugfix release for the Drupal 8.8.x series. Drupal 8.8.x will not receive any further development aside from security fixes. Sites should prepare to update to Drupal 8.9.0 or Drupal 9.0.0 for ongoing support.

Bug reports should be targeted against the 8.9.x-dev branch from now on, and new development or disruptive changes should be targeted against the 9.1.x-dev branch. For more information see the Drupal 8 and 9 minor version schedule and the Allowed changes during the Drupal 8 and 9 release cycles.

Version: 8.9.x-dev » 9.2.x-dev

Drupal 8 is end-of-life as of November 17, 2021. There will not be further changes made to Drupal 8. Bugfixes are now made to the 9.3.x and higher branches only. For more information see the Drupal core minor version schedule and the Allowed changes during the Drupal core release cycle.

Version: 9.2.x-dev » 9.3.x-dev

Version: 9.3.x-dev » 9.4.x-dev

Drupal 9.3.15 was released on June 1st, 2022 and is the final full bugfix release for the Drupal 9.3.x series. Drupal 9.3.x will not receive any further development aside from security fixes. Drupal 9 bug reports should be targeted for the 9.4.x-dev branch from now on, and new development or disruptive changes should be targeted for the 9.5.x-dev branch. For more information see the Drupal core minor version schedule and the Allowed changes during the Drupal core release cycle.

Version: 9.4.x-dev » 9.5.x-dev

Drupal 9.4.9 was released on December 7, 2022 and is the final full bugfix release for the Drupal 9.4.x series. Drupal 9.4.x will not receive any further development aside from security fixes. Drupal 9 bug reports should be targeted for the 9.5.x-dev branch from now on, and new development or disruptive changes should be targeted for the 10.1.x-dev branch. For more information see the Drupal core minor version schedule and the Allowed changes during the Drupal core release cycle.

quietone’s picture

Component: base system » extension system
mxmilkiib’s picture

Version: 9.5.x-dev » 11.x-dev