XF 2.0 Has addon data been fully imported during Setup's "postUpgrade" step?

DragonByte Tech

Well-known member
I'm creating an upgrade to one of our add-ons that will add some new settings to the XenForo Options, and will need to port data from a database table into these new settings.

I'm seeing this todo line: // TODO: check whether the the import job is still enqueued. If so, it won't have completed successfully. which would indicate that it cannot be guaranteed the import has completed successfully.

It's pretty imperative that the postUpgrade step only executes after import has completed. How likely is it to run into this race condition?


Fillip
 
Since there are already dozens of addons upgrading legacy XF1.5 to XF2, pretty unlikely I would say.
I'm not sure if that's relevant, the issue here is that I need to run a postUpgrade step that depends on the new data being in the xf_option table. If the enqueued import job has not finished, then there's a chance that the options data will not have been imported yet, and that the data won't exist in that table.

That is, if I'm reading the code right, I could be wrong.

In either case, I've added this bit to my upgrade step:
PHP:
            $options = $this->db()->fetchPairs("
                SELECT option_id, option_value
                FROM xf_option
                WHERE option_id LIKE 'dbtech_credits_eventtrigger_%'
            ");
            if (!count($options))
            {
                $stateChanges['redirect'] = \XF::app()->router('admin')
                    ->buildLink('dbtech-credits/upgrade-error')
                ;
            }

So if this condition happens, I'll at least be able to tell users what happened and direct them to the settings page to configure the options.


Fillip
 
I'm not sure if that's relevant, the issue here is that I need to run a postUpgrade step that depends on the new data being in the xf_option table.
That's pretty standard because many addons have a new structure (partly because of how XF2 is designed) so they depend on importing the data and then doing stuff with that, e.g. assigning permissions, rewards, connecting data to user accounts, etc. I'm assuming that the upgrade process is the same, no matter if it's a legacy addon or XF2->XF2 upgrade.
So IMHO it's really unlikely to run into a problem with this, otherwise the bug sections would've been overflooded already.
 
Back
Top Bottom