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

XF 2.0 Step Installer

katsulynx

Well-known member
#1
I've decided to make use of the step setup installer for my add-ons to split up different steps and make debugging in case of an error simpler. However, the thing I was asking myself is: If I call a setup step from within an upgrade step (see below for example), will this just execute the setup step or will this trigger any undesired behavior like executing the following steps as well?

PHP:
public function installStep6() {
    // Does Stuff
}

public function upgrade1000032Step1() {
    $this->installStep6();
}
 

Chris D

XenForo developer
Staff member
#2
I think that would work, but we would probably advise against it.

Although it's duplicative, you have to consider the impact if whatever happens in step 6 changes in a future version.

e.g. Install step 6 adds table X with column a, b and c. You later release beta 3 and have an upgrade step which adds column d to table X and update step 6 with the new column. Anyone still on beta 1 will go through all of the upgrade steps including the beta 2 step which just runs install step 6 which will give them table X with column a, b, c and d. Then they'll move on to the beta 3 step which will attempt to add column d again.

This has the scope to cause issues, so you should generally just consider upgrades to be a snapshot in time.
 

katsulynx

Well-known member
#3
e.g. Install step 6 adds table X with column a, b and c. You later release beta 3 and have an upgrade step which adds column d to table X and update step 6 with the new column. Anyone still on beta 1 will go through all of the upgrade steps including the beta 2 step which just runs install step 6 which will give them table X with column a, b, c and d. Then they'll move on to the beta 3 step which will attempt to add column d again.
That is actually already happening and I was just busy thinking about a solution for it. I'll probably just leave the 'duplicates' in there, if you recommend that as well. Better be safe than sorry.