XF 2.1 Run code after XenForo upgrade

Kirby

Well-known member
I'd like to run code after a XenForo upgrade has been performed. This is easily possible for Add-ons by listening on addon_post_upgrade, but this does not seem to be possible for XenForo itself although a XF Add-on does exist.

Does anyone (@ChrisD ?) have an idea how this could be done?
 
  • Like
Reactions: Xon
Add-ons (listeners) are explicitly and intentionally not run through the upgrade process so it's quite unlikely that anything would work. If something did, it'd probably have to be done via config.php though I'm not positive if that's still viable. (There isn't likely to be a relevant event being triggered.)
 
It's pretty nasty but you might want to have a Cron that runs semi-frequently comparing the last known version ID with the current version ID and then take action when you detect a change. Though you might also want to do additional checking to make sure there isn't an upgrade in progress - like the files having been uploaded but not yet having run the installer.

It should be a fairly lightweight check so you could run it every minute and clearly most of the time it will bail out because the IDs won't have changed.

I will now go and hang my head in shame for having suggested it, but I'll not criticise if you decide that's the only route to take ;)
 
I initially also thought about checking the version ID but tossed that idea as being kinda ugly ;)

Maybe it would be possible to enqueue an empty job (XF:UpgradeCompleted or smth. like this) that basically does nothing (except maybe firing a code event) at the end of XF\Upgrade::completeUpgrade()?

This could act as a trigger and would run outside the upgrade processes but would ensure it does get run after an upgrade and does not require "active wating" for a version ID change.[/icode]
 
Top Bottom