Module uninstall cleanup — custom cleanup scripts without core modifications

I’m working on a custom module and need to understand how module cleanup works during uninstallation.

Current situation:

The core uninstall process (module_manage_uninstallProcess.php) automatically removes:

  • Actions and permissions

  • Hooks

  • Settings (by scope)

  • Notification events

  • Module record

Database tables are only removed if the user selects them during uninstall.

Question:

Is there a way for a module to run custom cleanup code during uninstall without modifying core files? For example:

  • Deleting custom fields created by the module

  • Cleaning up file uploads

  • Removing related data from other tables

  • Other module-specific cleanup

What I’ve checked:

  • module_manage_uninstallProcess.php doesn’t include module-specific uninstall files

  • No hook/event system appears to be triggered during uninstall

  • The process seems to be a fixed sequence of operations

Goal:

I want to ensure my custom module cleans up all its resources on uninstall, but I don’t want to modify core files. Is there a supported extension point I’m missing, or would this require a core enhancement?

Thanks for any guidance.

Hi @WesselsOD, welcome to the Gibbon forums, it’s great to hear you’re up and running with custom module development.

This is an excellent question, and not something we’ve considered yet, but certainly something that would be good to add. You are correct in your assessment that module_manage_uninstallProcess.php file doesn’t include module-specific uninstall files.

We could definitely look at adding a hook to the uninstall process that modules could use to clean up their own files. I suspect this hook would be best to run before the automatic clean up, so that any existing database relations can be used to track down and clean up other records or files. Would this be something you would be interested in contributing to the core? Otherwise, I can add it to our development list for v31.

If you’re interested, we have a developer Slack, if you email support@gibbonedu.org we’d be happy to add you. Its a very quiet Slack, but can be a good place to get code-specific help.