I have a plugin that is using the Moodle Cache API, thus it is implementing the db/caches.php file along with source and loader classes.
When uninstalling this plugin I get a coding_exception in cache/classes/definition.php, as the cache definitions are loaded from the configuration in MUC (moodledata/muc/config.php). Although the plugin is removed from disk, the MUC still contains its cache definition and is looking for the source and loader files.
The question is then:
Is this a bug in the Moodle plugin uninstall process or do I have to implement some code in db/uninstall.php of my plugin to unregister the cache class?
There doesn't seem to be functions readily available for the latter in cache or cachehelper.
The code can be found here: https://bitbucket.org/laerdalmedical/moodle-ltisource_ecohub/
Thanks in advance!
There was no apparent solution to this, so I did a somewhat dirty hack:
Settings in caches.php is now included, depending on a singleton state so the caches.php appears empty when the state is set.
The state is not set anywhere but from within uninstall.php. When uninstalling, the state is set "disabling" the cache definition, then definitions are reloaded using the cache_helper::update_definitions function. This will reload all definitions except the one in my caches.php. Once reloaded, the state is reset.
Now the MUC is refreshed with all cached definitions, except the one from my, now uninstalled, plugin.
I wish there was a cleaner way to do this. Either by Moodle invalidating the definitions in MUC during plugin uninstall or by using a cache_helper function. The latter will require knowledge of the cache_helpers cache definition naming scheme as is.