Thread: [CS-Project-svn_notify] SF.net SVN: cs-project: [815] trunk/1.2/lib/upgradeClass.php
Brought to you by:
crazedsanity
From: <cra...@us...> - 2008-02-09 04:22:43
|
Revision: 815 http://cs-project.svn.sourceforge.net/cs-project/?rev=815&view=rev Author: crazedsanity Date: 2008-02-08 20:22:41 -0800 (Fri, 08 Feb 2008) Log Message: ----------- Check for invalid entry in upgrade.xml (which I had previously added). Modified Paths: -------------- trunk/1.2/lib/upgradeClass.php Modified: trunk/1.2/lib/upgradeClass.php =================================================================== --- trunk/1.2/lib/upgradeClass.php 2008-02-09 03:59:16 UTC (rev 814) +++ trunk/1.2/lib/upgradeClass.php 2008-02-09 04:22:41 UTC (rev 815) @@ -190,7 +190,7 @@ throw new exception(__METHOD__ .": upgrade already in progress...????"); } else { - $lockConfig = $this->upgrade_in_progress(TRUE); + $lockConfig = $this->upgrade_in_progress(); $this->fsObj->cd("/"); //TODO: not only should the "create_file()" method be run, but also do a sanity check by calling lock_file_exists(). @@ -819,7 +819,10 @@ foreach($this->config['MATCHING'] as $matchVersion=>$data) { $matchVersion = preg_replace('/^V/', '', $matchVersion); - if($this->databaseVersion == $matchVersion || $this->is_higher_version($this->databaseVersion, $matchVersion)) { + if($matchVersion == $data['TARGET_VERSION']) { + throw new exception(__METHOD__ .": detected invalid TARGET_VERSION in (". $matchVersion ."): make sure TARGET_VERSION is higher than matching!"); + } + elseif($this->databaseVersion == $matchVersion || $this->is_higher_version($this->databaseVersion, $matchVersion)) { //the version in MATCHING is equal to or HIGHER than our database version... make sure it is NOT // higher than the version in our versionFile. if(!$this->is_higher_version($this->versionFileVersion, $matchVersion)) { This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <cra...@us...> - 2008-02-09 05:33:33
|
Revision: 817 http://cs-project.svn.sourceforge.net/cs-project/?rev=817&view=rev Author: crazedsanity Date: 2008-02-08 21:33:30 -0800 (Fri, 08 Feb 2008) Log Message: ----------- Upgrade locks config again, plus more debug printing. Modified Paths: -------------- trunk/1.2/lib/upgradeClass.php Modified: trunk/1.2/lib/upgradeClass.php =================================================================== --- trunk/1.2/lib/upgradeClass.php 2008-02-09 04:23:14 UTC (rev 816) +++ trunk/1.2/lib/upgradeClass.php 2008-02-09 05:33:30 UTC (rev 817) @@ -190,7 +190,7 @@ throw new exception(__METHOD__ .": upgrade already in progress...????"); } else { - $lockConfig = $this->upgrade_in_progress(); + $lockConfig = $this->upgrade_in_progress(TRUE); $this->fsObj->cd("/"); //TODO: not only should the "create_file()" method be run, but also do a sanity check by calling lock_file_exists(). @@ -445,6 +445,7 @@ //version-only upgrade. $this->update_database_version($this->versionFileVersion); $this->newVersion = $this->versionFileVersion; + $this->gfObj->debug_print(__METHOD__ .": doing version-only upgrade..."); } else { $scriptIndex = $versionIndex; @@ -466,6 +467,7 @@ throw new exception(__METHOD__ .": target version not specified, unable to proceed with upgrade for ". $versionIndex); } } + $this->gfObj->debug_print(__METHOD__ .": done... "); }//end do_single_upgrade() //========================================================================= @@ -560,6 +562,7 @@ //we've got the filename, see if it exists. $fileName = UPGRADE_DIR .'/'. $myConfigFile; if(file_exists($fileName)) { + $this->gfObj->debug_print(__METHOD__ .": file exists... "); $createClassName = $upgradeData['CLASS_NAME']; $classUpgradeMethod = $upgradeData['CALL_METHOD']; require_once($fileName); This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <cra...@us...> - 2008-03-27 02:50:19
|
Revision: 853 http://cs-project.svn.sourceforge.net/cs-project/?rev=853&view=rev Author: crazedsanity Date: 2008-03-26 19:50:15 -0700 (Wed, 26 Mar 2008) Log Message: ----------- Use new constant for config file location, better error. Modified Paths: -------------- trunk/1.2/lib/upgradeClass.php Modified: trunk/1.2/lib/upgradeClass.php =================================================================== --- trunk/1.2/lib/upgradeClass.php 2008-03-27 02:49:13 UTC (rev 852) +++ trunk/1.2/lib/upgradeClass.php 2008-03-27 02:50:15 UTC (rev 853) @@ -68,7 +68,7 @@ if($this->upgrade_in_progress()) { throw new exception(__METHOD__ .": upgrade in progress"); } - elseif(!file_exists(dirname(__FILE__) .'/'. CONFIG_FILENAME)) { + elseif(!file_exists(CONFIG_FILE_LOCATION)) { throw new exception(__METHOD__ .": config.xml file missing"); } elseif(!file_exists(dirname(__FILE__) .'/../VERSION')) { @@ -147,7 +147,7 @@ $retval = NULL; if(!is_array($config) || !count($config)) { - throw new exception(__METHOD__ .": constant CONFIG_FILENAME not present, can't locate config xml file"); + throw new exception(__METHOD__ .": no configuration data available (missing config file?)"); } else { //now, let's see if there's a "version_string" index. @@ -203,7 +203,7 @@ $this->gfObj->debug_print(__METHOD__ .": result of setting 'upgrade in progress': (". $lockConfig .")"); //check to see if our config file is writable. - if(!$this->fsObj->is_writable("lib/config.xml")) { + if(!$this->fsObj->is_writable(CONFIG_FILE_LOCATION)) { throw new exception(__METHOD__ .": config file isn't writable!"); } @@ -625,7 +625,7 @@ //========================================================================= private function update_config_file($index, $value) { $gf = new cs_globalFunctions; - $myConfigFile = 'lib/'. CONFIG_FILENAME; + $myConfigFile = CONFIG_FILE_LOCATION; $fs = new cs_fileSystemClass(dirname(__FILE__) .'/../'); $xmlParser = new XMLParser($fs->read($myConfigFile)); $xmlCreator = new XMLCreator; This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <cra...@us...> - 2008-05-13 00:21:49
|
Revision: 893 http://cs-project.svn.sourceforge.net/cs-project/?rev=893&view=rev Author: crazedsanity Date: 2008-05-12 17:21:44 -0700 (Mon, 12 May 2008) Log Message: ----------- Fixes for critical issue #188. /lib/upgradeClass.php: * read_upgrade_config_file(): -- if there are multiple entries beneath "MATCHING", and the first index doesn't start with "V", assume it is numerically indexed, and the index beneath the number is the actual version we're looking for. * parse_version_string(): -- if either version is less than or equal to 4 characters, it throws an exception (because "x.x.x" is the smallest length valid version string). -- check that putting the parsed data back together from the array is identical to the given version number. * is_higher_version(): -- better debug_print() data. * get_upgrade_list(): -- check to ensure $dbVersion and $newVersion both appear to contain valid version information. Modified Paths: -------------- trunk/1.2/lib/upgradeClass.php Modified: trunk/1.2/lib/upgradeClass.php =================================================================== --- trunk/1.2/lib/upgradeClass.php 2008-05-12 22:35:11 UTC (rev 892) +++ trunk/1.2/lib/upgradeClass.php 2008-05-13 00:21:44 UTC (rev 893) @@ -178,6 +178,20 @@ $config = $xmlParser->get_tree(TRUE); $this->config = $config['UPGRADE']; + + //now fix the "MATCHING" section as needed. + $matchingKeys = $this->config['MATCHING']; + + $myMatching = $this->config['MATCHING']; + unset($this->config['MATCHING']); + if(!preg_match('/^V/', $matchingKeys[0])) { + foreach($myMatching as $index=>$data) { + $keys = array_keys($data); + $this->config['MATCHING'][$keys[0]] = $myMatching[$index][$keys[0]]; + } + } + debug_print($this->config); + }//end read_upgrade_config_file() //========================================================================= @@ -272,7 +286,8 @@ //========================================================================= public function parse_version_string($versionString) { - if(is_null($versionString) || !strlen($versionString)) { + if(is_null($versionString) || !(strlen($versionString) > 4)) { + cs_debug_backtrace(1); throw new exception(__METHOD__ .": invalid version string ($versionString)"); } $tmp = explode('.', $versionString); @@ -322,6 +337,16 @@ $retval['version_suffix'] = ""; } + //double-check our data matches the initial version string. + $checkThis = $retval['version_major'] .".". $retval['version_minor'] .".". $retval['version_maintenance']; + if(strlen($retval['version_suffix'])) { + $checkThis .= "-". $retval['version_suffix']; + } + + if($checkThis != $versionString) { + throw new exception(__METHOD__ .": initial version string (". $versionString .") doesn't match final (". $checkThis .")"); + } + return($retval); }//end parse_version_string() //========================================================================= @@ -718,7 +743,7 @@ } else { //TODO: should there maybe be an option to throw an exception (freak out) here? - debug_print(__METHOD__ .": while checking ". $index .", realized the new version (". $checkIfHigher .") is LOWER than current (". $version .")",1); + debug_print(__METHOD__ .": while checking ". $index .", realized the new version (". $checkIfHigher .") is LOWER than current (". $versionNumber .")",1); } } else { @@ -814,6 +839,10 @@ $dbVersion = $this->databaseVersion; $newVersion = $this->versionFileVersion; + if((strlen($dbVersion) <= 4) || (strlen($newVersion) <= 4)) { + throw new exception(__METHOD__ .": invalid data in dbVersion (". $dbVersion .") or newVersion (". $newVersion .")"); + } + $retval = array(); if(!$this->is_higher_version($dbVersion, $newVersion)) { throw new exception(__METHOD__ .": version (". $newVersion .") isn't higher than (". $dbVersion .")... something is broken"); This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |