glFusion Wiki

Site Tools


glfusion:development:tips

Coding Tips, Techniques & Best Practices

On this page, you can find some useful tips, checklists and other things that you might find useful as you perform tasks which requires the modification of the glFusion codebase.

Modifying the glFusion Schema

There are a number of different places in the code that require modification to support graceful changes to the glFusion schema. When doing this, it is important to ensure you are updating the glFusion script and database version (GVERSION), and also ensuring that the installation and upgrade scripts work properly.

In the checklist below, if you are modifying changes to the core SQL structure, you will be progressing from {old_glfusion_version} to {new_glfusion_version}. Changes to the plugin SQL structures also require that you advance the plugin version number, and you will be progressing from {old_pi_version} to {new_pi_version}.

Core/Bundled Plugin SQL Structure Changes

1) public_html/admin/install/dvlpupdate.php: Add DB_query()'s as required to modify the schema in the manner desired to the new glfusion_{new_glfusion_version}() function, and also ensure that the {glfusion} var in gl_vars is being updated with the value of {new_glfusion_version}. This script simulates what the install upgrade script does, but is a little handier to use for the developer/tester.

2) public_html/admin/install/include/install.lib.php: Find the function INST_doDatabaseUpgrades(). Add a case statement for {old_glfusion_version}, and then add DB_query()'s as required to modify the schema. Again, don't forget to UPDATE the {glfusion} var with the value of {new_glfusion_version] to signify that the updates have been performed. This ensures that the system upgrade script will make the necessary modifications to the schema.

Core SQL Structure Changes (only)

3) private/sql/mysql_tableanddata.php: Add the relevant structural changes to the appropriate CREATE TABLE statement. This script is used to create the glFusion schema when a new installation is performed.

Bundled Plugin SQL Structure Changes

4) private/plugins/{plugin}/sql/mysql_install.php: Add the relevant structural changes to the appropriate CREATE TABLE statement. This script is used when the plugin is installed to create the plugin's data structures.

5) private/plugins/{plugin}/plugin.xml: Roll the <version> value forward to {new_pi_version}.

6) private/plugins/{plugin}/{plugin}.php: Roll $pi_version forward to {new_pi_version}, and also change gl_version to {new_glfusion_version}.

7) private/plugins/{plugin}/upgrade.php: Add DB_query()'s as required to modify structure, add DB_query() to update the pi_version value for this plugin in gl_plugins to {new_pi_version}. This ensures that the plugin upgrade script works properly.

8) public_html/admin/install/dvlpupdate.php: Add the DB_query()'s as required to modify structure, also add DB_query() to update the pi_version value for this plugin in gl_plugins to {new_pi_version}. This is the script that developers/testers use to 'sync' the schema to the current development code.

glfusion/development/tips.txt · Last modified: 2017/04/12 21:11 (external edit)

Page Tools