This is a follow-up from #228860: Upgrading a module with a newly added dependencies breaks things badly.

The patch from there will prevent the update script (update.php) from running if a module's dependcies are not met. Sometimes newer versions of a module will add/change dependencies, thus it is necessary to check the dependencies on every update.

However, some people discussed also implementing this as a runtime check as well. There are a few issues with that:

  1. What's the performance impact? The runtime checks only runs within the admin menu, but the check makes an expensive call to system_rebuild_module_data().
  2. Is it necessary? Drupal best practices state that update.php should be run every time a module is updated.

Another issue discussed was whether we should also provide a way to resolve unmet dependencies in addition to detecting them.

If I forget anything, feel free to mention it here.

Support from Acquia helps fund testing for Drupal Acquia logo

Comments

catch’s picture

There are some pages in core - admin/modules is one, where we already call system_rebuild_module_data(), and there's a pending patch to add a static cache for that, so it only runs once per page. So when that static cache is in, adding it to pages which already run that check ought to have minimal performance impact. However it gets really, really expensive when you have lots of modules (c9... measured around 4 seconds) so adding it to pages where it's not already I'd really want to avoid.

For unmet dependencies, for D7 I don't think we can do more than warn. There's an issue to add a recovery.php somewhere, and it's also been discussed adding some of that wsod recovery to the update manager since that's already a minimally bootstrapped environment where you can affect your installation.

tstoeckler’s picture

As Jacob Singh brought up in #228860: Upgrading a module with a newly added dependencies breaks things badly an unmet dependency can completely kill your site if the module implements a class of the missing module.
Hence, I don't think the performance impact is worth it, because we are only catering for people, who:

  1. Don't visit update.php after uploading a new version of a module. (which we discourage, anyway, as stated above)
  2. Have the luck of uploading a module which doesn't implement a class of a newly added dependency. (which we have absolutely no control over)

Regarding the second point mentioned in the OP, on update.php on the 'Verify Requirements' page, where the error is shown, if there is an unmet dependency, it should give the option to enable the dependency (if it is available) or disable the depending module. That way, if you simply forgot to install the new module you can do so (or first download it and then do so), or if you are not sure, whether you actually want to install the dependency on your site (for whatever reason), you can disable the module that requires it, if you know that disabling that module is not going to eat your site.

tstoeckler’s picture

Here's how it could look.

tstoeckler’s picture

Issue tags: +Needs usability review

Tagging.
The strings in the screenshots are:

@module1 requires this module. You can either install @module2 or disable @module1 module.

@module1 requires this module. You can either install @module2 or disable @module1 module.

Do you really want to install @module2 module?

Do you really want to disable @module1 module?

Mike Wacker’s picture

What could make this quite interesting is that Drupal is not fully bootstrapped when update.php runs. If a module implements hook_enable/disable/install(), could it be possible that it would run code that would not work unless Drupal was fully bootstrapped?

Garrett Albright’s picture

It appears that installation profiles are (unnecessarily?) being considered as modules in regards to dependency checking. I made a new install with the "Standard" install profile, then disabled the Overlay module. I then used CVS to update a contrib module and went to run update.php, but got hit with this error: "Unresolved dependency - Overlay (Disabled) - Standard requires this module." If I re-enable Overlay, I can then run update.php as normal. Lame! Especially considering how I usually disable Color and Comment as well. Is there a particular reason we can't exclude installation profiles from this dependency checking, at least as far as update.php is concerned?

agentrickard’s picture

@Garrett

We split that install profile issue off over here --> #808162: update.php fails when optional modules disabled

Mike Wacker’s picture

Issue tags: +String freeze

This adds some new UI text, so tagging with 'string freeze'

Mike Wacker’s picture

Issue tags: -String freeze

Tagged the wrong issue, oops :O

pillarsdotnet’s picture

Version: 7.x-dev » 8.x-dev
Component: update system » install system

This is especially problematic when the added dependency is required by a hook_init() implementation. It's very easy to WSOD a site that way. In my modules, I've had to add code like

if (!module_enabled('dependency_module')) {
  module_disable(array('this_module'));
  drupal_set_message('BIG FAT WARNING');
  drupal_goto('admin/modules');
}
pillarsdotnet’s picture

Plagiarizing the excellent summary by KarenS:

A module may add a new dependency -- which could be a dependency on another module, a requirement for a higher version of PHP, or a later version of a previously required module. If the new dependency is not met, it creates several additional problems:

  1. If the module it is dependent on is not enabled, the checkbox to enable it cannot be checked on the modules page, it is an empty, disabled checkbox.
  2. The missing dependency makes it dangerous to run updates.
  3. The missing dependency may create fatal errors which make it impossible to get to the modules page to enable the required module.
  4. The required module may be missing, so there may be no way to enable it.
  5. A D6 -> D7 upgrade creates additional problems because you can't get to the modules page to manually enable newly required modules until at least the core updates have run, but if you run update.php to update core you will also update modules with missing dependencies.
  6. In all cases, the administrator should be warned that a dangerous instability exists.
  7. The patch in this issue addresses (1) and (2) and partially addresses (6) -- it does not warn the administrator unless they go to update.php.

Note that the referenced patch has been committed, so only #3-5 and part of #6 are still unresolved.

Bojhan’s picture

Status: Active » Needs work
Issue tags: -Needs usability review +Usability

Seems like a useful improvement, can this get a update?

mondrake’s picture

Category: Task » Bug report
Priority: Normal » Critical
Issue summary: View changes

I have just released Textimage 8.x-3.0-alpha2. In this release I added a dependency to the image_effects module. Updating from Textimage 8.x-3.0-alpha1 (which did not have the module dependency), it looks like there is no check on the newly added dependency. So I end up trying to use Textimage functionalities without the image_effects module installed, and get fatal errors :(

If I uninstall Textimage and try to reinstall, everything works - the installer finds the dependency, proposes to install image_effects too, and confirming I get both modules installed.

mondrake’s picture

Steps to reproduce:

  • Install Textimage 8.x-3.0-alpha1, configure it, create an Image Style using the Textimage Text image effect
  • Check for available updates (Manage>Reports>Available Updates), ensure the check is fresh, it should say there's alpha2 available
  • Update to alpha2 through the update process
  • Edit the Image Style created at the beginning, fatal error
catch’s picture

Priority: Critical » Major

So this is definitely major, but I don't think it's critical. In stable contrib releases, a new dependency should mean a new branch for that module and have a prominent mention in the release notes, and there should be a hook_update_N() to install the dependency.

Or there are other ways to mitigate it like provide a temporary compatibility layer for the new dependency and warn people they need to update it in an interim release - so at least they can go pre-depencency -> compat version -> no-compat.

But in terms of what core can do, if you have code that has a hard dependency on code that's not there, and that code is in the critical path of a Drupal site, Drupal itself isn't going to be able to do much to resolve it. Possibly rebuild.php could detect the missing dependency and warn loudly?

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.

keesje’s picture

Using features module for a configuration management approach, depends on changing module dependencies to work in a lot of scenario's. Related: https://www.drupal.org/node/2726839

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.

Pasqualle’s picture

Version: 8.6.x-dev » 8.9.x-dev
Pasqualle’s picture

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

Drupal 8.9.0-beta1 was released on March 20, 2020. 8.9.x is the final, long-term support (LTS) minor release of Drupal 8, which means new developments and disruptive changes should now 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: 9.1.x-dev » 9.2.x-dev

Drupal 9.1.0-alpha1 will be released the week of October 19, 2020, which means new developments and disruptive changes should now be targeted for the 9.2.x-dev branch. For more information see the Drupal 9 minor version schedule and the Allowed changes during the Drupal 9 release cycle.

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

Drupal 9.2.0-alpha1 will be released the week of May 3, 2021, which means new developments and disruptive changes should now be targeted for the 9.3.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.3.x-dev » 9.4.x-dev

Drupal 9.3.0-rc1 was released on November 26, 2021, which means new developments and disruptive changes should now be targeted for the 9.4.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.0-alpha1 was released on May 6, 2022, which means new developments and disruptive changes should now 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.5.x-dev » 10.1.x-dev

Drupal 9.5.0-beta2 and Drupal 10.0.0-beta2 were released on September 29, 2022, which means new developments and disruptive changes should now 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.

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

Drupal core is moving towards using a “main” branch. As an interim step, a new 11.x branch has been opened, as Drupal.org infrastructure cannot currently fully support a branch named main. New developments and disruptive changes should now be targeted for the 11.x branch, which currently accepts only minor-version allowed changes. For more information, see the Drupal core minor version schedule and the Allowed changes during the Drupal core release cycle.