As designed CLI addon-upgrade enable disabled addons

Affected version
2.0

developr

Active member
Hi there,

when I use php cmd.php xf:addon-upgrade XXX/YYY -n to a disabled addon it will enabled automatically after upgrade.

I think this it not useful. I disable addons (not uninstall) to keep all data but I would like to upgrade it for security reasons.

Bug or feature?
 

DragonByte Tech

Well-known member
This happens with the GUI upgrade too so I'm fairly certain it's intended. Usually the reason why someone would want to disable then upgrade an add-on is not for security reasons, but for integrity reasons.

Meaning, let's say I release a massive update that changes some core files and adds a whole bunch of new stuff. Somewhere in there, I make references to stuff that isn't in the database yet, or a new event listener, etc. If the addon isn't disabled prior to upgrade, that could lead to the site crashing. Not a security flaw, just means you have to disable listeners, then disable the addon, then upgrade.

Hopefully that made some amount of sense :D
 

Mike

XenForo developer
Staff member
It is as designed and it's necessary/required. Add-ons can take actions after upgrading to do things like rebuilds and they need to be able to assume that the add-on is enabled.
 

developr

Active member
Ok, I understand you. But when it's should be required to disable an addon manually before upgrading then it should be enabled manually.

Or it could be a part of the upgrade routine:
  • enabled addons
    • disable addon automatically
    • upgrade addon
    • enable addon automatically
  • disabled addons
    • only upgrade addon
Or let the user choice with a additional parameter like the -n parameter for noninteractive.

Edit: Mike was faster then me.
 

developr

Active member
Does it make sense to disallow upgrades if an addon is disabled?

I also can not upgrade an uninstalled addon.

Or is it possible to get the status via cli?
 

Mike

XenForo developer
Staff member
Does it make sense to disallow upgrades if an addon is disabled?
No, because it is potentially possible to get into a situation where you can't enable the add-on to do the upgrade (because it triggers something incompatible with the version of XF in use).
 

developr

Active member
Hm I try to build a bash script for remote upgrades. It works fine but everytime I have to check and switch the status before and after upgrading manually.
 

Jake B.

Well-known member
Hm I try to build a bash script for remote upgrades. It works fine but everytime I have to check and switch the status before and after upgrading manually.
There is an xf:addon-disable CLI command to disable an add-on, so if your goal is to automate it using some deployment tools or a CI you can use that to disable the add-on again after you've upgraded it. If you attempt to disable an add-on that is already disabled it'll just give you feedback that it's already disabled without performing any additional actions
 

developr

Active member
Yes, I know this command but how could you check the status via bash if the addon was disabled before the upgrade?
Maybe mysql -e but I hoped that there exists an easier solution.
 
Top