WordPress.org

Ready to get started?Download WordPress

Forums

Trigger plugin delete without proper file permissions (11 posts)

  1. ti2m
    Member
    Posted 1 year ago #

    My plugin comes with custom tables which I want to delete when the plugin gets deleted, not when it just gets deactivated. I though I could use the deactivation and uninstall hook for this. Unfortunately the uninstall hook does not get triggered when wordpress can't delete the according plugin files.

    For me, deleting tables + settings and files are two different things. For a user who has access to the files, but no FTP access, he is able to delete the files manually, but he will be left with the tables. Am I missing something? Searched the codex and looked it up in "wordpress professional", but right now it looks like the uninstall hook gets only triggered after file delete permissions are checked???

    Thanks for a hint

  2. ti2m
    Member
    Posted 1 year ago #

    Just to mention this, for now I added a checkbox to the plugin settings page which lets you decide to run the uninstall function for my plugin on deactivation, but that can't be it....

    Sorry, can someone please move this into the "Hacks" forum, I was to quick.

  3. esmi
    Forum Moderator
    Posted 1 year ago #

    Have a look through the scripts for http://wordpress.org/extend/plugins/eshop/ It has the kind of delete functionality that you're after.

  4. ti2m
    Member
    Posted 1 year ago #

    Thanks for the hint. But by looking at it the plugin seems to provide an additional menu link which lets you uninstall it. That's basically what I have done with the checkbox.

    So there is no way of triggering the uninstall hook when you don't have the proper file permissions? I would call that a major issue considering how wired the file permission are set on many hosts.

  5. esmi
    Forum Moderator
    Posted 1 year ago #

    when you don't have the proper file permissions

    Well, the whole point of file permissions is to stop "unauthorised" manipulation of files & folders. So I doubt you'll find another way around this.

  6. ti2m
    Member
    Posted 1 year ago #

    I totally agree on that, but it's about cleaning out the DB. Lot of users have wired file permission setups (as I got from the plugin issue queue) which don't reflect at all what they should be able to do and what not.
    I would expect the core plugin uninstall interface to let you choose what you want to delete. Maybe I want to start fresh with a plugin because I messed it up and therefore keep the files but clean out the DB settings....

    I do understand that this functionality doesn't exist (thanks for the answers, that already helps me a lot), I'm just trying to understand why.

  7. esmi
    Forum Moderator
    Posted 1 year ago #

    it's about cleaning out the DB

    That shouldn't be affected by file permissions, so I'm afraid I'm not following you here.

    [Note: This could be more to do with my still flu-addled brain than anything else.]

  8. ti2m
    Member
    Posted 1 year ago #

    Oh, I know how that feels, thanks for making the effort of helping then even more!

    My problem is that I want to delete a custom table and some plugin option settings on uninstall. As far as I can tell the uninstall hook of my plugin gets never called when trying to uninstall it, because the file permission check is being done and fails. Basically I want to delete some DB settings, but WP tells me I can't because I don't have the proper file permissions settings to delete the plugin files, which I'm not even interested in ;-)

    I find the way Drupal does this intuitive: Download and enable plugin (same WP), deactivate (same WP), uninstall (means kill all DB settings of the plugin, fresh start) and the delete files manually. For the last two step WP tries to do that in one and if you don't have file permission access through WP you can't do any of it.

    I think removing plugins in a clean way is really important for the stability of the whole system and I find it strange that it is tied to file permission which some users might not be willing to hand out to the server or what not.

  9. esmi
    Forum Moderator
    Posted 1 year ago #

    because the file permission check is being done and fails

    Could this just be a script flow issue? Are you trying to remove the db tables after the file permissions check? Or before? The latter would seem to be the best approach.

  10. ti2m
    Member
    Posted 1 year ago #

    Sorry, I can't follow.

    In includes/plugins.php uninstall_plugin() (which will trigger the uninstall hooks) gets called by delete_plugins() AFTER delete_plugins() checks the file permissions. I don't see a way how I can influence that, that would require a core change.

  11. ti2m
    Member
    Posted 1 year ago #

    So I talked to a couple of WP devs and this seems to be a common "issue" although I can't really convince that many people that it is in fact an issue and an inconsistency. Fine with me after all, I just needed to know that there is no other way then to set up an option within the plugin settings.

Topic Closed

This topic has been closed to new replies.

About this Topic

Tags

No tags yet.