[geeklog-devel] plugin_autoinstall - two more issues
Joe Mucchiello
joe at ThrowingDice.com
Tue Oct 6 09:54:38 EDT 2009
At 09:26 AM 10/6/2009, Randy Kolenko wrote:
> > returned by plugin_autoinstall_foo it's own function. If the function
> > was successful, it returned a string containing a SQL statement that
> > would undo whatever that function just did. This value is assigned
>
>So, how does returning 1 line of sql help remove data structures created
>in a dependent plugin's table structure -- especially when the table
>structure is relational?
>
>I would have thought a simpler approach would have been to include the
>failed installed plugin's functions.inc file and simply call the
>autouninstall function to cleanly uninstall it.
>You have to write the uninstall function anyways, so might as well use
>it properly.. The original bug noted by Blaine is that the PLG_uninstall
>will never work during a failure in the autoinstall method due to the
>functions.inc file not being included for the failed plugin.
You missed the point that each line of the autoinstall structure is a
function call and that those functions return the sql. So for every
group created, every feature created, every group to feature mapping,
every table created, every group added to another group, etc. a
separate SQL statement is returned. The INSTALLER_install_table
function returns a DROP TABLE $tablename string. The
INSTALLER_install_group function returns a DELETE FROM groups....
string. The mapping lines return the string to clean the
group_assignments table.
The reason not to call the uninstall function is to simplify the
uninstalll code. Usually a failed install fails in the middle. With
the reversal strings you only undo what actually was done. Uninstall
functions might attempt to do things to files on the filesystem or
make updates to other tables. When you only undo the minimum there is
less risk of collateral damage. And the uninstall function only has
to be written to uninstall a proper installation. It doesn't need to
worry about partial installs.
Oh, and if you really wanted to just use the uninstall, you should
move the uninstall function to the autoinstall.php file and include
that during uninstall not the other way around. Again, some
functions.inc files make database calls outside of all functions. If
the plugin failed to install, this will most like cause errors.
Including the functions.inc is therefore potentially dangerous. The
autoinstall.php is designed to be called while the plugin does not
exist. In addition, normal operation of the site would no longer have
to parse the uninstall function with every web hit. During 99.99% of
the time that is dead code.
----
Joe Mucchiello
Throwing Dice Games
http://www.throwingdice.com
More information about the geeklog-devel
mailing list