craft-plugin-commands icon indicating copy to clipboard operation
craft-plugin-commands copied to clipboard

[bug] Attempting to uninstall a plugin that is not installed does not throw an error

Open tomdavies opened this issue 5 years ago • 2 comments
trafficstars

This is probably a fairly inconsequential bug, but it caught me today (due to a typo I made in a plugin handle) so thought I'd raise it.

Using plugin/uninstall to attempt to uninstall a craft plugin that is not installed does not throw an error when the command is run.

i.e.:

$ ./craft plugin/uninstall non-existent-plugin-handle

gives:

> Uninstalled non-existent-plugin-handle successfully

i.e. a false positive success

Craft's Plugins service throws an InvalidPluginException which from a quick look it looks like your code should catch, so it's not 100% obvious why this is happening.

Let me know if you want me to make a reduced test case.

tomdavies avatar Aug 18 '20 10:08 tomdavies

Oh, Craft introduced its own plugin/* commands now. They use the same try/catch https://github.com/craftcms/cms/blob/3.5/src/console/controllers/PluginController.php#L66-L71 and it fails (with success) the same way. All other commands work as expected for unknown plugins.

This is the reason: https://github.com/craftcms/cms/blob/3.5/src/services/Plugins.php#L571

ostark avatar Aug 18 '20 20:08 ostark

I believe this is a Craft CMS core issue based on this issue

jamesmacwhite avatar Feb 04 '22 15:02 jamesmacwhite