News:

Wondering if this will always be free?  See why free is better.

Main Menu

FYI Mod Authors - 2.0 <database> and <code> use

Started by Arantor, July 21, 2014, 10:58:11 PM

Previous topic - Next topic

Arantor

This is something I keep seeing, so I need to write it out clearly because this is behaviour that needs to change.

When installing:
Only <database> to load your install script. You can add hooks or tables in here. $smcFunc['db_create_table'] should be used wherever possible.

This makes sure that tables are created and *properly logged when installing* so that they can be cleaned up later on.

When uninstalling:
Use <database> ONLY if there are things that need cleaning up when the user selects the option for removing all mod data, but separate to cleaning out tables your mod created. You might use this if you want to purge smf_settings of settings related to your mod (which won't be cleaned out any other way)

Use <code> to clean up your hooks and scheduled tasks and other things that must be cleaned regardless.

<code> is always run on uninstall, <database> is only run if the user elects to clean house on the mod (which only worked if <database> was used on install)


For an example of this, see SimpleDesk:
install.php - adds tables, rows to tables, scheduled tasks, and hooks
uninstall-required.php - removes hooks and things that must be disabled (e.g. scheduled tasks)
uninstall-optional.php - removes settings

Please do this in future if possible because it means users are likely to end up with a cleaner system afterwards; it's nice not to have to go pruning legacy hook calls and stuff like that.

Thanks :)

Ninja ZX-10RR

Indeed I have seen many mods "badly" made in that way. I mean that they leave some stuff and you have to manually remove it. The point is not only that, it's that sometimes they don't even warn you about it, it's not just annoying it's irritating.
Thanks for the instructions hopefully someone will actually read them :)
Quote from: BeastMode topic=525177.msg3720020#msg3720020
It's so powerful that on this post and even in the two PMs you sent me,you still answered my question very quickly and you're apologizing for the delay. You're the #1 support I've probably ever encountered man, so much respect for that. Thank you, and get better soon.

I'll keep this in my siggy for a while just to remind me that someone appreciated what I did while others didn't.

♥ Jess ♥

STOP EDITING MY PROFILE

Advertisement: