Unable to delete a plugin

Unable to delete a plugin

by Juho Jaakkola -
Number of replies: 2

I'm unable to delete a plugin. There is no "Uninstall" link in the Plugin Overview page. If I delete the directory, Moodle tells me that the plugin is "Missing from disk".

What are possible causes for this? It's an authentication plugin that I've created myself. Could there be something wrong with my code?

I was wondering whether it cannot be removed because there are users who have registered using it. However the "Uninstall" link didn't appear despite deleting all the users created with it.

I'm using Moodle 2.7+ (Build: 20140515).

Average of ratings: -
In reply to Juho Jaakkola

Re: Unable to delete a plugin

by David Mudrák -
Picture of Core developers Picture of Documentation writers Picture of Moodle HQ Picture of Particularly helpful Moodlers Picture of Peer reviewers Picture of Plugin developers Picture of Plugins guardians Picture of Testers Picture of Translators

Deleting accounts does not help. You must change the auth method for those users (there is an option to do it in bulk IIRC). I am afraid that now your users are deleted, you only can change the auth method for them in the database.

The code that controls this is in lib/classes/plugininfo/auth.php:

public function is_uninstall_allowed() {
    global $DB;

    if (in_array($this->name, array('manual', 'nologin', 'webservice', 'mnet'))) {
        return false;
    }

    return !$DB->record_exists('user', array('auth'=>$this->name));
}

And because user records are not actually deleted from the database (just marked as deleted), this returns false for you now. I agree it may be actually seen as a bug now, as the record_exists() check should take the deleted accounts into account.

Average of ratings: Useful (2)