[Cs-webdbupgrade-commits] SF.net SVN: cs-webdbupgrade:[24] trunk/0.1/cs_webdbupgrade.class.php
Status: Inactive
Brought to you by:
crazedsanity
From: <cra...@us...> - 2009-08-04 16:38:42
|
Revision: 24 http://cs-webdbupgrade.svn.sourceforge.net/cs-webdbupgrade/?rev=24&view=rev Author: crazedsanity Date: 2009-08-04 16:38:31 +0000 (Tue, 04 Aug 2009) Log Message: ----------- Set initial version when loading table into database. /cs_webdbupgrade.class.php: * __construct(): -- use a separate connection for the logger so logs don't disappear with transactions if they get rolled-back. * read_upgrade_config_file(): -- catch exceptions from cs_fileSystem{} and wrap its own exception around it, so the error is easier to debug. * load_table(): -- call read_upgrade_config_file() to see if there is an INITIAL_VERSION to use instead of using the standard versionFileVersion (which potentially skips intermediate updates). Modified Paths: -------------- trunk/0.1/cs_webdbupgrade.class.php Modified: trunk/0.1/cs_webdbupgrade.class.php =================================================================== --- trunk/0.1/cs_webdbupgrade.class.php 2009-08-04 15:40:42 UTC (rev 23) +++ trunk/0.1/cs_webdbupgrade.class.php 2009-08-04 16:38:31 UTC (rev 24) @@ -128,7 +128,10 @@ $this->db = new cs_phpDB(constant('DBTYPE')); try { $this->db->connect($this->config['DBPARAMS']); - $this->logsObj = new cs_webdblogger($this->db, "Upgrade"); + + $loggerDb = new cs_phpDB(constant('DBTYPE')); + $loggerDb->connect($this->config['DBPARAMS'], true); + $this->logsObj = new cs_webdblogger($loggerDb, "Upgrade"); } catch(exception $e) { $this->gfObj->debug_print($this->config,1); @@ -235,7 +238,12 @@ * Read information from our config file, so we know what to expect. */ private function read_upgrade_config_file() { - $xmlString = $this->fsObj->read($this->config['UPGRADE_CONFIG_FILE']); + try { + $xmlString = $this->fsObj->read($this->config['UPGRADE_CONFIG_FILE']); + } + catch(exception $e) { + throw new exception(__METHOD__ .": failed to read upgrade config file::: ". $e->getMessage()); + } //parse the file. $xmlParser = new cs_phpxmlParser($xmlString); @@ -934,7 +942,15 @@ //now set the initial version information... if(strlen($this->projectName) && strlen($this->versionFileVersion)) { - $insertData = $this->parse_version_string($this->versionFileVersion); + + //if there's an INITIAL_VERSION in the upgrade config file, use that. + $this->read_upgrade_config_file(); + if(isset($this->config['UPGRADELIST']['INITIALVERSION'])) { + $insertData = $this->parse_version_string($this->config['UPGRADELIST']['INITIALVERSION']); + } + else { + $insertData = $this->parse_version_string($this->versionFileVersion); + } $insertData['project_name'] = $this->projectName; $sql = 'INSERT INTO '. $this->config['DB_TABLE'] . $this->gfObj->string_from_array($insertData, 'insert'); This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |