MyBB Community Forums

Full Version: Include delete function for plugins
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
Hey,

how about to include a default delete function for plugins?

Like this:
[attachment=44852]

Plugin developers could include a new function into their plugins, what return a file list of this plugin.

Like:
function hello_delete()
{
 return array(
 'inc/languages/{lang}/hello.lang.php', // {lang} -> catches all installed language files like this
 'inc/languages/{lang}/admin/hello.lang.php', // {lang} -> catches all installed language files like this
 'inc/plugins/hello.php'
 );
}

If someone push this to GH then I could offer a PR for it. Smile
if you want i can custom plugin to do this.
Plugins files are usually not writable so this wouldn't work in most cases.
(2022-01-22, 08:02 AM)StefanT Wrote: [ -> ]Plugins files are usually not writable so this wouldn't work in most cases.

Hey Stefan,

I've tested the function several times local and online and it works every time.
My web server has a default configuration so that uploaded plugin files will get permissions 644.

I have created a pull request on GitHub ... maybe someone could test/check it.
I included it in some of my plugins but as @StefanT said in most cases it doesn't work.
A way it could be implemented is to check if all files are writable and if so add the delete button, otherwise show a button that displays all the plugin files so the user know what files to delete to remove the plugin.
(2022-01-22, 09:55 AM)SvePu Wrote: [ -> ]My web server has a default configuration so that uploaded plugin files will get permissions 644.
The most common (and recommended) configuration is to have separate users for PHP and FTP. That means PHP can't modify or delete any files unless you manually grant additional permissions.
(2022-01-22, 09:55 AM)SvePu Wrote: [ -> ]I have created a pull request on GitHub ... maybe someone could test/check it.
The developers will most likely reject it because they announced there won't be any new features in 1.8.x: https://blog.mybb.com/2021/05/17/looking-to-the-future/
(2022-01-23, 12:52 AM)chack1172 Wrote: [ -> ]A way it could be implemented is to check if all files are writable and if so add the delete button, otherwise show a button that displays all the plugin files so the user know what files to delete to remove the plugin.
This sounds good to me. Also if a plugin includes a list of its files it might be useful to check that it's installed properly before being able to activate it.
(2022-01-23, 09:40 AM)StefanT Wrote: [ -> ]
(2022-01-23, 12:52 AM)chack1172 Wrote: [ -> ]A way it could be implemented is to check if all files are writable and if so add the delete button, otherwise show a button that displays all the plugin files so the user know what files to delete to remove the plugin.
This sounds good to me. Also if a plugin includes a list of its files it might be useful to check that it's installed properly before being able to activate it.

What about plugins with dependencies or relation with other plugins ? And translations added by the user ?
(2022-01-23, 09:40 AM)StefanT Wrote: [ -> ]
(2022-01-22, 09:55 AM)SvePu Wrote: [ -> ]My web server has a default configuration so that uploaded plugin files will get permissions 644.
The most common (and recommended) configuration is to have separate users for PHP and FTP. That means PHP can't modify or delete any files unless you manually grant additional permissions.
(2022-01-22, 09:55 AM)SvePu Wrote: [ -> ]I have created a pull request on GitHub ... maybe someone could test/check it.
The developers will most likely reject it because they announced there won't be any new features in 1.8.x: https://blog.mybb.com/2021/05/17/looking-to-the-future/
(2022-01-23, 12:52 AM)chack1172 Wrote: [ -> ]A way it could be implemented is to check if all files are writable and if so add the delete button, otherwise show a button that displays all the plugin files so the user know what files to delete to remove the plugin.
This sounds good to me. Also if a plugin includes a list of its files it might be useful to check that it's installed properly before being able to activate it.

(2022-01-23, 09:54 AM)Crazycat Wrote: [ -> ]
(2022-01-23, 09:40 AM)StefanT Wrote: [ -> ]
(2022-01-23, 12:52 AM)chack1172 Wrote: [ -> ]A way it could be implemented is to check if all files are writable and if so add the delete button, otherwise show a button that displays all the plugin files so the user know what files to delete to remove the plugin.
This sounds good to me. Also if a plugin includes a list of its files it might be useful to check that it's installed properly before being able to activate it.

What about plugins with dependencies or relation with other plugins ? And translations added by the user ?

Somewhat related:

The plan for 1.9 is to allow plugins to be released and installed as Composer packages. This essentially means that all of a plugin's files will live inside a single folder (e.g. inc/vendor/Foo/Bar). The  composer.json file will be used to specify dependencies on other plugins/packages and we'll have some way of publishing front-end assets (e.g. images, CSS, JS).

This would allow for easy automatic deletion and cleanup.

We will be continuing to support the existing approach for a while too, but having a well defined standard structure for plugins will make everybody's lives easier in the future.
Re the original feature request, my Plugin Uploader plugin dos this but it has to fall back to using FTP functions to delete the files (and upload them in the first place) for the reasons Stefan mentioned, as usually PHP won't have permission if the FTP user created the files/folder, which is why it wouldn't work for most installs. It's the same reason settings.php almost always needs to be CHMOD to 666 to b writable - it may work with 644 on your system but won't for the vast majority.
Thank you all for your feedback..I added a file writable check into function now - delete button will not shown if file are unwritable.

If it will not integrated by default I've to include it into my plugins in the future. It's only a kind of service for admins. Wink