1. This site uses cookies. By continuing to use this site, you are agreeing to our use of cookies. Learn More.

Writing an upgrade script for an addon

Discussion in 'XenForo Development Discussions' started by SheepCow, Mar 19, 2011.

  1. SheepCow

    SheepCow Well-Known Member

    Is there a tutorial / sample anywhere on how to write an upgrade script for an addon?

    Basically I need to remove event listeners not used any more, simply updating with the XML file adds the new ones but doesn't seem to remove existing?

    Also will need to delete old addon files ...

    In the addon you can define install/uninstall, does the existing uninstall get called before the new install function?
  2. Jeremy P

    Jeremy P Well-Known Member

    Your updated XML should not include old event listeners if you removed them prior to generating it. Could be it's callback method hasn't been updated to exclude the old classes?

    Deleting files, imo, isn't the job of the install/uninstaller. However, you can Google around for the appropriate functions.

    Install gets called on install and upgrade, uninstall only gets called on uninstall.
  3. SheepCow

    SheepCow Well-Known Member

    Yeah it looks like I had managed to export the XML before I'd actually finished!

    For anyone interested, the install() function gets called with 2 parameters during an upgrade. The first parameter is the existing addon information (an array from the model, or boolean false if not already installed) and the second is the addon information of the one being installed.

Share This Page