I have developed two plugins (auth and mod) that have each other as a dependency. I have noticed that this creates a deadlock when trying to uninstall any of the two plugins because neither can be removed since it's required by the other one. (If there is a way to deinstall multiple plugins at once, I couldn't figure it out.)
What's the best thing to do in this case? Keep the dependencies and accept that the moodle admin will have a hard time deinstalling the plugins? Or should I rather remove the dependency entry for one of the plugins, even though there is dependency from a technical perspective?
To be honest, I like neither of those options.
one way could be to create a dummy local plugin which only contents the dependencies of your plugins.
If you want to uninstall your plugins you must uninstall your local-plugin at first and after that the other plugins.
thanks for your reply. But to be honest, I gave your idea some thought and I don't really get how this solves the issue.
I can think of the following cases:
[auth] -depends-> [local] <-depends- [mod]
There is no dependency between auth and mod, which renders the local one rather useless.
[auth] <-depends-> [local] <-depends-> [mod]
The admin won't be able to uninstall any of them.
[auth] <-depends- [local] -depends-> [mod]
There is no dependency between auth and mod.
local depends on auth
local depends on mod
It's like compose, which I think about.
Once the local plugin is installed all dependencies must be resolved.
This way you could add more dependencies later into your local plugin to ensure all needed things are installed.
Of course you have to provide some documentation about the installation of the local plugin. But you are not in a dead lock.
- Do not specify any dependency and just provide documentation to maintainers that these plugins depend on each other
- Create third plugin that call's code from both plugins. That third plugin will depend on both plugins. Which means once your admin removes that third plugin you can uninstall the other two.
For example if third plugin is called local_foo and the other two are auth_myplugin and enrol_myplugin the version.php of that one might look like this:
$plugin->version = 2019061300;
$plugin->requires = 2015051100;
$plugin->component = 'local_foo';
$plugin->release = '1.0';
$plugin->maturity = MATURITY_STABLE;
$plugin->dependencies = [
'auth_myplugin' => ANY_VERSION,
'enrol_myplugin' => ANY_VERSION
What's the best thing to do in this case?
The best thing is to provide a patch fixing the Moodle core so that the uninstaller detects the circular dependencies and can uninstall the plugins correctly. Also related is MDL-56624