MyBB Community Forums

Full Version: Modifying the MyBB Upgrade Script - Questions
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
Hello All,

I have a few questions about how the MyBB upgrade script works. I'm trying to modify the upgrade script to work with my MyBB Multiforums Script, so instead of updating one forum I need it to update many forums at once. I'm looking over the code on how to best do this, but I'm a little lost, so here goes:

First off, when doing the upgrade, instead of getting the table prefix for the database from config.php, I want to get it from the database. I have a table named hosted_forums in my database that contains the name of each forum, like firstforum, secondforum, etc, so for the table prefix I could easily append an underscore to the forum name like firstforum_ and use that as the table prefix. I also noticed the code below in the upgrade script and I assume that this is where the table prefix is defined:

define('TABLE_PREFIX', $config['database']['table_prefix']);

Anyway, what I want to have is where the upgrader, step by step is run on a loop for all forums, so each step of the upgrade when run is run for all forums, not just one. So, I am wondering where the best place to put loops as well as defining the table prefix would be in the upgrade script so that I may run each step for all forums at once. Should I put one loop covering a large area or a loop for each function, etc...

Also, another problem I am having is with trying to figure out what to do about settings.php and the upgrader. My multiforums script modifies MyBB so that settings.php is never used, everything is kept in the database. So, one question is, looking at the code, I assume that the rebuild_settings() function is responsible for grabbing the current settings from the database? Am I correct in saying this?

Also, am I correct in saying that the function sync_settings() works by updating the settings in the database? Also, will it be possible to upgrade the settings for the forums without them having a settings.php and everything is just in the database?

Any help or comments you have would really help me out. I wish too the upgrader script was commented better. Smile

Thanks all,
You might be able to achieve the upgrade script updating all your forums at once by using MyBB's use of round-robin database support by faking a write connection for every forum you have setup in the database (You might want to test this though considering it could be hugely processor intensive and you might run into timeout issues especially during a 1.2 -> 1.4 upgrade [or any major release])

Your correct with rebuild_settings and sync_settings
Thanks Ryan, could you go into a bit more detail about how I would go about that? I have somewhat of an idea of what I think that meant, but I'm not quite sure if I'm on track.

It's setting up more connections in inc/config.php - I believe I discussed this in Part 3 of the ACP Blog.
Ok, thanks. I'll have to look at that. Smile