[CS-Project-svn_notify] SF.net SVN: cs-project: [893] trunk/1.2/lib/upgradeClass.php
Brought to you by:
crazedsanity
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. |