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
- Have a site where
webform_update_8114()is still pending. - Ensure the
contributemodule is no longer present in the filesystem. - Run
drush updb. - 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
contributemodule 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
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
Comment #4
liam morlandThanks for the patch.
This can probably be improved through the use of
ExtensionList::exists().Bug reports are always against the development branch.