Problem/Motivation

webform_update_8114() is intended to clean up configuration related to the deprecated contribute module when that module is no longer present in the filesystem.

However, the update hook assumes that the following call will always return a path string:

\Drupal::service('extension.list.module')->getPath('contribute')

This is not always true. When the contribute module does not exist in the codebase, Drupal throws Drupal\Core\Extension\Exception\UnknownExtensionException.

As a result, webform_update_8114() can fail before reaching the cleanup logic it is meant to execute.

Steps to reproduce

  1. Have a site where webform_update_8114() is still pending.
  2. Ensure the contribute module is no longer present in the filesystem.
  3. Run drush updb.
  4. The update fails when calling extension.list.module->getPath('contribute').

This can also be confirmed directly with:

drush php:eval 'var_export(\Drupal::service("extension.list.module")->getPath("contribute"));'

When the module is missing, this throws UnknownExtensionException instead of returning a path.

Proposed resolution

Catch UnknownExtensionException before checking whether the module still exists on disk.

This preserves the current intent of the update hook:

  • If the contribute module still exists, return early.
  • If the module is already missing, continue the cleanup safely.

Remaining tasks

  • Review and apply the patch.
  • Verify the update on a site where webform_update_8114() is still pending.
  • Optionally add a regression test for the missing-module case.

User interface changes

None.

API changes

None.

Data model changes

None beyond the cleanup already intended by webform_update_8114().

Issue fork webform-3586019

Command icon Show commands

Start within a Git clone of the project using the version control instructions.

Or, if you do not have SSH keys set up on git.drupalcode.org:

Comments

visbee created an issue. See original summary.

liam morland’s picture

Version: 6.3.0-beta7 » 6.3.x-dev
Status: Active » Needs work

Thanks for the patch.

This can probably be improved through the use of ExtensionList::exists().

Bug reports are always against the development branch.