Score:1

How can I detect when a stream wrapper is uninstalled?

ve flag

Does Drupal provide an "uninstall" hook to get notified when a Drupal Stream Wrapper is removed/uninstalled?

Or, is there a way to prevent a custom Drupal stream wrapper from being removed/uninstalled while there is at least one Drupal File entity that is using the stream wrapper?

Currently, for example, a Drupal site will crash if I do the following:

  1. Install a custom stream wrapper (e.g., https://www.drupal.org/project/s3fs)
  2. Add a File field to a Node and configure the file field to use this stream wrapper
  3. Store a file with the file field above
  4. Uninstall the custom stream wrapper's module
  5. Try to view the file field's contents by opening the node's page (which will attempt to fetch & render the file).
Score:2
id flag

Yes. The module providing the stream wrapper should implement an uninstall validator, that checks for usages.

user1414202 avatar
ve flag
Got it. Is there any alternative solution (apart from editing the providing module to add an uninstall validator) if the module providing the stream wrapper doesn't also provide an uninstall validator that checks for usages?
sonfd avatar
in flag
Submit an issue to the module's issue queue on drupal.org and add a patch that adds the uninstall validator for the module. Then apply the patch to your project via composer.
mangohost

Post an answer

Most people don’t grasp that asking a lot of questions unlocks learning and improves interpersonal bonding. In Alison’s studies, for example, though people could accurately recall how many questions had been asked in their conversations, they didn’t intuit the link between questions and liking. Across four studies, in which participants were engaged in conversations themselves or read transcripts of others’ conversations, people tended not to realize that question asking would influence—or had influenced—the level of amity between the conversationalists.