Fixed Code event listeners left in during uninstall callback error.

Liam W

in memoriam 1998-2020
I just (finally) figured out why my tags aren't working - the code event listeners for the MultiPrefix add-on were left behind when the uninstall callback errored out.

The add-on was deleted from the database, but it's event listeners weren't - and they were still being run.

This is really a bug - if the add-on doesn't exist, then any listeners associated with it should be removed one way or another.

Liam

EDIT: Actually, I think everything was left behind (at least template mods were as well).
 
Last edited:
This is sort of triggered by a limitation in MySQL's transactions. MySQL immediately closes the current transaction when it comes to a DDL statement (alter, drop table, etc). So if a later element caused a failure, the add-on entry would already be removed.

There are limited options of how to deal with this because we can't prevent this behavior and the callback is arbitrary (and likely to contain DDLs). The only thing we can do is move the callback to be the last step of the postSave process. This does mean that any of the add-on associated data would be removed by that point, but I'm not sure when an add-on would actually need that. Because there is a possibility though, I'm only making this change for 1.5.
 
I feel like it might be better to leave the add-on entry in case the uninstall callback fails (which from what Mike has said, sounds like is not the current behavior either). This way the uninstall can be reattempted later.

If the add-on had made major changes on the database end, or the user is trying to uninstall+reinstall the add-on, leaving the database in this pseudo-uninstalled state can be problematic.

This way, if the add-on cannot be fully uninstalled because of a faulty callback, then the add-on list will reflect this, and users can post a bug report to the add-on like a cryptic "can't uninstall", rather than letting everyone think the uninstall was successful and having potential issues down the line.

(While the author addresses such reported uninstall issues, the users can still disable the add-on).
 
Back
Top Bottom