SourceBans icon indicating copy to clipboard operation
SourceBans copied to clipboard

Fixed bug with plugin status on install/uninstall

Open ppalex7 opened this issue 11 years ago • 4 comments

At 95ac85c6d453fed166994e11a883bdc63a871e7a plugin installation system was broken, and saves status of installation/deinstallation as 'success' in all cases. I fixed it.

Saving plugin status as 'installed'/'uninstalled' only if corresponding action finished properly Also added messages for failed plugin installation.

ppalex7 avatar Jan 25 '14 11:01 ppalex7

I don't think this is necessary, as you can see in the Community Bans plugin, the new way is to throw an exception. The error message is then returned via AJAX. The documentation in SBPlugin just wasn't updated.

ErikMinekus avatar Jan 28 '14 17:01 ErikMinekus

Maybe, but why if I return false from runInstall - plugin will marked as installed?

ppalex7 avatar Jan 28 '14 17:01 ppalex7

Why break something that already works?

Or if you think, that throwing exception - is only right way - you should edit documentation of SBPlugin model in the part of "return value of runInstall or runUninstall functions"

ppalex7 avatar Jan 28 '14 17:01 ppalex7

Maybe, but why if I return false from runInstall - plugin will marked as installed?

Because it doesn't check for false anymore, it checks whether an exception was thrown.

Why break something that already works?

Sure, returning false worked, except that you had no idea what went wrong. Now you actually get an error message.

Or if you think, that throwing exception - is only right way - you should edit documentation of SBPlugin model in the part of "return value of runInstall or runUninstall functions"

I don't think it's the only right way, but for now it's the easiest way to stop the installation and return an error message. Especially since Yii also throws exceptions for SQL errors and such. Maybe in the future we'll want to return multiple error messages, then we can reconsider how it's implemented.

I updated the documentation in commit 7b145fbc1ef7e61060a39b399cd493057509c2a3.

ErikMinekus avatar Jan 28 '14 19:01 ErikMinekus