ElkArte Community

Title: Hooks not removed when package uninstalled
Post by: scripple on March 14, 2014, 03:02:12 am
Testing with spuds hideusernames packages (and my own package) I noticed that after uninstalling the package the integrate_xxx hook variables are still set in the settings table of the database.
Title: Re: Hooks not removed when package uninstalled
Post by: emanuele on March 14, 2014, 04:52:16 am
/me feels guilty
Title: Re: Hooks not removed when package uninstalled
Post by: emanuele on March 14, 2014, 06:32:26 pm
Which one is it the package?

I did a very quick test putting:
Code: [Select]
<?php
require_once('SSI.php');

add_integration_function('testing', 'test_func', 'BOARDDIR/test.php');
remove_integration_function('testing', 'test_func', 'BOARDDIR/test.php');
and few variants in a file and running it, but hooks are properly removed.
Title: Re: Hooks not removed when package uninstalled
Post by: scripple on March 14, 2014, 07:29:11 pm
I tested with spuds hide user names package.  You can find a copy attached in the thread about errors installing a package.
Title: Re: Hooks not removed when package uninstalled
Post by: scripple on March 14, 2014, 09:52:31 pm
I see the problem.  I believe you have already fixed it just in a later version of the trunk than I have.

In remove_integration_hook

if (strpos($funcfile, '|') !== false)  should be   if (strpos($filefunc, '|') !== false)

Not sure if you care about this, but if the last function for a particular hook is removed the database entry still exists just with an empty value.

Title: Re: Hooks not removed when package uninstalled
Post by: emanuele on March 15, 2014, 04:47:06 am
Oh okay, that one!

Quote from: scripple – Not sure if you care about this, but if the last function for a particular hook is removed the database entry still exists just with an empty value.
Is annoying, isn't it?
Will have a look.
Title: Re: Hooks not removed when package uninstalled
Post by: emanuele on March 15, 2014, 09:30:43 am
In the meantime I added some tests for adding/removing hooks:
https://github.com/emanuele45/Dialogo/commit/eebb4f83cc6a379c0c5e3f3b51bba9420110fcba

And removed also empty hooks:
https://github.com/emanuele45/Dialogo/commit/4daef7d0185f283fccf87ebf081762e1d16f7070