Implemented Add option to completely remove add-ons

Snog

Well-known member
Since we can install from archive, I don't think there's any reason we couldn't have a "Remove add-on" option for add-ons that have been uninstalled.

I THINK it would just be a matter of reading the add-on's hashes.json file and deleting the files/folders listed in it.

remove.webp
 
Last edited:
Upvote 91
This suggestion has been implemented. Votes are no longer accepted.
This can be a good idea to... as of now I go through my DIR and remove the files but automating it can make life easier
 
Last edited:
I THINK it would just be a matter of reading the add-on's hashes.json file and deleting the files/folders listed in it.

What happens with files that are shipped with multiple add-ons, such as shared libraries in that case? It's a bit more complex than it seems on a first glance.
 
What happens with files that are shipped with multiple add-ons, such as shared libraries in that case? It's a bit more complex than it seems on a first glance.
Perhaps the solution would be for add-ons that do this to use a separate core add-on, like TH does for themes (the UIX add-on).

Or exclude certain directory names (such as Core) from being deleted if there are other folders that still exist for that developer.
 
Perhaps the solution would be for add-ons that do this to use a separate core add-on, like TH does for themes (the UIX add-on).
We don't do this to share functionality, but to do stuff that is unfortunately not possible with themes alone. From a user perspective, it's unfortunately super unnecessary clutter.
 
We don't do this to share functionality, but to do stuff that is unfortunately not possible with themes alone. From a user perspective, it's unfortunately super unnecessary clutter.
I know that, it was just a very general example.

I haven't seen any add-ons that use a completely shared library yet. I've seen add-ons that add to a common folder (like Core). That's not to say they don't exist. And that's not to say TH doesn't do it since I don't have all of TH add-ons to know if they do or don't. ;)
 
What happens with files that are shipped with multiple add-ons, such as shared libraries in that case? It's a bit more complex than it seems on a first glance.
How about flagging them programatically and not allowing them to be removed, if such a system is implemented which removes addon files? Those files would be skipped. And maybe a log somewhere in the ACP mentioning which files are skipped, so one can clear them later.
 
I think the easiest way would be for a standard to be set where any shared libraries would have to be in either a "Common" or "Core" folder for a developer.

Then if any other folders remain after the removal of an add-on, the "Common" or "Core" folder wouldn't be touched. If NO other folders remain after the removal of an add-on, then and only then the "Common" or "Core" folder would also be removed.
 
What happens with files that are shipped with multiple add-ons, such as shared libraries in that case? It's a bit more complex than it seems on a first glance.
As long as an add-on's hashes in their hashes.json aren't shared with any other add-on it should be safe to delete a file references in hashes.json. Probably want other sanity check as well.

No shared by any other add-on (which includes XF) gets the 'last vendor add-on results in shared files being removed' behaviour @Snog suggested for free.
 
As long as an add-on's hashes in their hashes.json aren't shared with any other add-on it should be safe to delete a file references in hashes.json.

Absolutely!

Maybe @XDinc wants to share his addon with us here on XF, until the option is officially created?

We can conclude with many methods.This sample will allow you to remove files!

PHP:
namespace Your\Namespace\XF\Admin\Controller;

use XF\Mvc\ParameterBag;

class YourClass extends XFCP_AddOn
{
    public function actionDeleteFiles(ParameterBag $params)
    {
        $addOn = $this->assertAddOnAvailable($params['addon_id_url']);
       
        if (!$addOn->canInstall())
        {
            return $this->error(\XF::phrase('x_files_of_this_add_on_can_not_be_removed_reason'));
        }
       
        $warnings = [];

        if (!$addOn->hasHashes())
        {
            $warnings[] = \XF::phrase('x_hashes_file_for_this_add_on_missing');
        }
       
        if ($this->isPost())
        {
            if ($addOn->hasHashes())
            {
                foreach ($addOn->getHashes() as $path => $hash)
                {
                    unlink($path);
                }
            }
           
            $addOnDirectoryIterator = new \RecursiveDirectoryIterator($addOn->getAddOnDirectory(), \FilesystemIterator::SKIP_DOTS);
            $addOnRecursiveIterator = new \RecursiveIteratorIterator($addOnDirectoryIterator, \RecursiveIteratorIterator::CHILD_FIRST);
            foreach ($addOnRecursiveIterator as $file)
            {
                $file->isDir() ?  rmdir($file) : unlink($file);
            }
           
            if (file_exists($addOn->getAddOnDirectory()))
            {
                rmdir($addOn->getAddOnDirectory());
            }
           
            return $this->redirect($this->buildLink('add-ons'));
        }
        else
        {
            $viewParams = [
                'addOn' => $addOn,
                'warnings' => $warnings
            ];
            return $this->view('your_remove_templates', $viewParams);
        }
    }
}
 
So you posted this thread for almost a year ago but nothing has changed. The ADD On's that ever were installed on the sever still stay there with the INSTALL button. Why is it so difficult for the developer of Xenforo to make a function that removes the entire ADD ON + ALL files if you click the REMOVE button?

Do they have any interest in that their customers get left with a mess of a forum filled with unused and even insecure files?
 
Since the function is not there, simply remove any files that were associated with the addon after you uninstalled it. Any “mess” left after uninstalling an addon is ultimately your responsibility to ensure is cleaned up.
 
That is very true. We are all responsible for our own forum and work. So why not put this function into Xenforo rather then let be up to each forum owner to esnure everything is removed.

Your comment makes absolute no sense @ozzy47
 
I don't think this should be implemented, the reason why? I've read here of bugs that pop up that can cripple a forum after un-installing an add-on, because the developer has not taken the time to ensure all related data is removed when the add-on is uninstalled. This way, they can re-install it to make the errors go away and report it to the developer in question. For my self, I search everything after I un-install an add-on I created: phrases, templates, tables, columns, options, content types, permissions, everything, and if anything is left over, I fix the issue(s) before it is released. When an add-on is removed it should leave your forum in the same state as before it was installed, but as been reported here, that does not always happen.

And of course, if this was implemented, files would not be removed in development mode.
 
I agree, uninstalling and removing files should be done with care and not by some automated process. Maybe once an addon is uninstalled, and admins have verified everything is functioning correctly, then have a button to click to remove the files.
 
I agree, uninstalling and removing files should be done with care and not by some automated process. Maybe once an addon is uninstalled, and admins have verified everything is functioning correctly, then have a button to click to remove the files.
this woulld be hard unless if they have one specific addon folder but some addon use styles, src, data, and so on and let say themehouse and XFA that have addons depending on each other it would be a disaster if you removed those files
 
Back
Top Bottom