I was upgrading webfomr 3.x to 4.x version,
While running update.php, I came across a situation where update stops at webform_update_7425().

It happens because, site didn't have views module installed while webform 4.x assume it is installed in hooks
webform_update_7425() and webform_update_7427().

Even though webform.info has dependencies[] = views , it would be great, if webform module have check to see if views is enabled or not if not, do enable it.

It can be added under webform_requirements().

if (!module_exists('views')) {
  $result = module_enable(array('views'));
 
  if (empty($result)) {
    throw new DrupalUpdateException(implode(', ', $modules) . ' or dependencies could not be enabled');
  }
}
Support from Acquia helps fund testing for Drupal Acquia logo

Comments

dineshw created an issue. See original summary.

DanChadwick’s picture

Version: 8.x-4.x-dev » 7.x-4.x-dev
Category: Bug report » Feature request
Priority: Major » Normal
Issue tags: -module updates, -hook_update_n, -dependencies

Would be a nice enhancement for those who don't read the documentation before updating.

dineshw’s picture

@Dan: should I create a patch for same? Would like to help on this.

DanChadwick’s picture

Absolutely!

DanChadwick’s picture

Any progress on your patch? I think the requirements should return an error, rather than raise an exception. It appears that update.php checks the requirements first.

DanChadwick’s picture

This is trickier than it appears. There are two significant differences between updating with drush and with update.php:

  1. update.php checks hook_requirements and refuses to update if there is a REQUIREMENTS_ERROR. drush updatedb does not
  2. update.php will automatically enable dependencies defined in the .info file. drush updatedb will not

See this issue in the github drush queue: https://github.com/drush-ops/drush/issues/1427

The consequence is that adding a hook_requirements() can prevent the update from running if executed via the update.php, but it does not prevent the issue with drush. Throwing an exception won't help because the requirements are never checked.

I believe the best course of action is to add the requirement to hook_requirements() and to throw the exception in the hook_update_N functions that require views.

DanChadwick’s picture

Status: Active » Fixed
FileSize
2.67 KB

Committed to 7.x-4.x. No corresponding issue for D8 exists because the update path for D7 to D8 will be different and view is in D8 core.

  • DanChadwick committed 733ea82 on 7.x-4.x
    Issue #2560339 by DanChadwick: Fixed webform 3.x to 4.x upgrade when...
dineshw’s picture

@DanChadwick Perfect :)

Status: Fixed » Closed (fixed)

Automatically closed - issue fixed for 2 weeks with no activity.