ChrisTERiS Posted July 22, 2017 Share Posted July 22, 2017 I'm a bit confused with version numbers and how to update them. Maybe because I've in mind how vBulletin keeps updates. Let's say that my initial file has the code: // ######################## MODULE CONFIGURATION ######################## function forum_config() { $configarray = array( "name" => "whmcsBB", "description" => "Community Bulletin Board", "version" => "1.0.0", "author" => "ChrisTERiS", "language" => "english", "fields" => array( )); return $configarray; } // ########################## ACTIVATE MODULE ########################### function forum_activate() { .......... here SQL to create tables............... } // ######################### DEACTIVATE MODULE ########################## function forum_deactivate() { ......... here SQL to drop any database changes........... } That's works fine for initial installation, so no problem. Now let's come to update to version 1.1.0. The code is: function forum_upgrade($version) { global $db; # Run SQL Updates for V1.0.0 to V1.1.0 if ($version == '1.0.0') { echo '1'; // Settings mysqli_query($db,"ALTER TABLE mod_forum_settings ADD rating TINYINT(1) DEFAULT '1' NOT NULL"); mysqli_query($db,"ALTER TABLE mod_forum_settings ADD social TINYINT(1) DEFAULT '1' NOT NULL"); // Usergroups mysqli_query($db,"ALTER TABLE mod_forum_usergroups ADD forum_html TINYINT(1) DEFAULT '0' NOT NULL"); // Update Version mysqli_query($db,"UPDATE tbladdonmodules SET value='1.1.0' WHERE module='forum' AND setting='version'"); } } ........ and in function forum_output($vars) I've added....................... // ########################### MODULE OUTPUT ############################ function forum_output($vars) { ............................................. // Version $version = $vars['version']; if($version <> '1.1.0') { $upgrade = forum_upgrade($version); } .................. That's also works fine. Have checked the database and new fields appear to be there. My Questions are: 1.- When I'm updating a module, do I need (like with vBulletin) to update version number in function forum_config() or let it to version 1.0.0 as it was the initial release? 2.- Even if in database I can see in table tbladdonmodules that the mod got the new version (eg module='forum', setting='version', value='1.1.0', in Setup-> AddOns I'm still seeing the old version (1.0.0) 3.- Placing an echo command within function forum_upgrade($version) function forum_upgrade($version) { global $db; # Run SQL Updates for V1.0.0 to V1.1.0 if ($version == '1.0.0') { echo '1'; } } I can see that it always goes there. Am I doing something wrong? Thank you Chris 0 Quote Link to comment Share on other sites More sharing options...
ChrisTERiS Posted July 25, 2017 Author Share Posted July 25, 2017 Nobody knows? Seems that I'll bypass whmcs functions and create my own to work with updates. 0 Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.