Index: branches/5.2.x/core/install/prerequisites.php =================================================================== diff -u -N -r15130 -r15176 --- branches/5.2.x/core/install/prerequisites.php (.../prerequisites.php) (revision 15130) +++ branches/5.2.x/core/install/prerequisites.php (.../prerequisites.php) (revision 15176) @@ -1,6 +1,6 @@ Array ('from' => '5.0.0-B1', 'to' => '5.1.0-B1'), + '5.1.0' => Array ('from' => '5.1.0-B1', 'to' => '5.2.0-B1'), + '5.2.0' => Array ('from' => '5.2.0-B1', 'to' => '5.3.0-B1'), + ); + + /** * Sets common instance of installator toolkit * * @param kInstallToolkit $instance @@ -52,7 +64,7 @@ * * @return kDBConnection */ - function &getConnection() + function getConnection() { return $this->_toolkit->Conn; } @@ -68,26 +80,30 @@ { $errors = Array (); - if ($mode == 'upgrade') { + if ( $mode == 'upgrade' ) { $sql = 'SELECT Version FROM ' . TABLE_PREFIX . 'Modules WHERE Name = "In-Portal"'; + $inportal_version = $this->getConnection()->GetOne($sql); - $conn =& $this->getConnection(); - $inportal_version = $conn->GetOne($sql); - - if ($inportal_version === false) { - // only, when In-Portal was installed + if ( $inportal_version === false ) { + // only, when In-Portal was installed (below 4.3.x) return $errors; } - $min_version = '4.3.1'; + $min_version = '4.3.1'; // K4-based installator was created, that no longer maintained old upgrade scripts - $current_version = $this->_toolkit->ConvertModuleVersion($inportal_version); - $needed_version = $this->_toolkit->ConvertModuleVersion($min_version); - if ($current_version < $needed_version) { - $errors[] = 'Please upgrade "In-Portal" to version ' . $min_version; + if ( version_compare($inportal_version, $min_version, '<') ) { + $errors[] = 'Please upgrade "In-Portal" to version ' . $min_version . ' first'; } + + // example: to upgrade to 5.1.0-B1 or more you at least need to have 5.0.0 installed + foreach ($this->upgradeRules as $min_version => $version_rules) { + if ( version_compare($versions[0], $version_rules['from'], '<') && version_compare($versions[1], $version_rules['to'], '>=') ) { + $errors[] = 'Please upgrade "In-Portal" to version ' . $min_version . ' first'; + break; + } + } } return $errors; @@ -166,7 +182,7 @@ $ret = Array(); $sql = 'SELECT VERSION()'; - $conn =& $this->getConnection(); + $conn = $this->getConnection(); $db_version = preg_replace('/[^\d.]/', '', $conn->GetOne($sql)); $ret['version'] = version_compare($db_version, '5.0', '>=');