[geeklog-devel] Upgrading from 1.4.1 to 1.5

Joe Mucchiello joe at ThrowingDice.com
Sun Dec 30 02:46:44 EST 2007


Has anyone upgraded an existing site? Not only are there still 1.4.2 
references in the code but this happens since Aaron's last changes:

Fatal error: Call to undefined method config::create() in 
D:\webroot\strip\sql\updates\mysql_1.4.1_to_1.4.2.php on line 41

Additionally, the staticpage config settings get lost. The 
admin/index.php install/upgrade has a loop that calls config->set to 
move existing data into the config class but that wasn't added to 
staticpages. In fact, the old staticpages config.php is blown away by 
untarring the tarball.

I suggest a change to the $config->add function to make bootstrapping 
the config database easier. Currently there's no way to set both a 
default value and current value. By overloading the $set variable, 
this can easily be accomplished without littering the code with 
isset() or array_key_exists calls.

+        if (is_array($set))  && array_key_exists($param_name, $set)) {
+           $value = serialize($set[$param_name]);
+        } else if ($set) {
+            $value = serialize($default_value);
+        } else {
+            $value = 'unset';
+        }
         $Qargs = array($_TABLES['conf_values'],
                        $param_name,
-                       $set ? serialize($default_value) : 'unset',
+                       $value,

Then you can use  the existing config.php to load the data:

// currently this is in the staticpages/config.php so it would have 
to be moved. probably to plugin_upgrade_staticpages in functions.php
if (!$sp_config->group_exists('staticpages')) {
     $_SP_CONF = array();
     @include $_CONF['path'].'plugins/staticpages/config.php'; // if 
there is no config.php, the default values are still added.

     $sp_config->add('version', '1.5', 'text', 0, 0, null, 0, 
$_SP_CONF, 'staticpages');
     $sp_config->add('allow_php', 1, 'text', 0, 0, null, 0, 
$_SP_CONF, 'staticpages');
     ...
     unset($_SP_CONF);
}

$_SP_CONF &= $sp_config->get_config('staticpages');

For this to work though, the existing config.php files must removed 
from the distribution.


----
Joe Mucchiello
Throwing Dice Games
http://www.throwingdice.com 




More information about the geeklog-devel mailing list