The best way to "step" through an install/upgrade process?

Jaxel

Well-known member
#1
I'll be updating one of my addons soon. I'll need to go through all existing rows of a table, analyze a single column, and make alterations to the data in that column. I couldn't just select all rows and step through each row, because there could be 10,000 rows and that would hang the install. So I'll need to do this in a 100 rows-at-a-time process.

Does anyone have any examples of how they have done this in the past? Hopefully showing progress to the user?
 

Chris D

XenForo developer
Staff member
#2
Probably a good candidate to defer it, which is an approach we've taken with some XFMG upgrades. e.g.
PHP:
if ($version < 901000170)
{
    XenForo_Application::defer('XenGallery_Deferred_MediaRating', array(), 'XFMGMediaRatingRebuild', true, XenForo_Application::$time + 5);
}
The "true" argument here makes it a manually triggered process which means it will execute in the "Rebuilding caches" stages alongside the standard phrases, templates rebuild etc.

You can then cycle through the records you need to in as many batches as you need to while displaying the progress.
 

Jaxel

Well-known member
#4
The "true" argument here makes it a manually triggered process which means it will execute in the "Rebuilding caches" stages alongside the standard phrases, templates rebuild etc.
What if I want it to run before the rebuilding section? During the install file step. I don't really want it deferred... I want it running in time.
 

Chris D

XenForo developer
Staff member
#5
Any chance you have an example anywhere of this deferment?
Loads of examples in the XenForo/Deferred directory.

What if I want it to run before the rebuilding section? During the install file step. I don't really want it deferred... I want it running in time.
It's as close to the install file step you're going to get. It will run automatically as soon as the install file step has completed.
 
Top