Fix version comparisons with -stable suffix (#1488876)

pull/53/head
Aleksander Machniak 12 years ago
parent a8ffab3f4f
commit a079269166

@ -1,6 +1,7 @@
CHANGELOG Roundcube Webmail
===========================
- Fix version comparisons with -stable suffix (#1488876)
- Add unsupported alternative parts to attachments list (#1488870)
- Add Compose button on message view page (#1488747)
- Display 'Sender' header in message preview

@ -35,7 +35,7 @@ if (!preg_match('/define\(.RCMAIL_VERSION.,\s*.([0-9.]+[a-z-]*)/', $iniset, $m))
$oldversion = $m[1];
if (version_compare($oldversion, RCMAIL_VERSION, '>='))
if (version_compare(version_parse($oldversion), version_parse(RCMAIL_VERSION), '>='))
die("Installation at target location is up-to-date!\n");
echo "Upgrading from $oldversion. Do you want to continue? (y/N)\n";

@ -34,7 +34,7 @@ if (!$opts['version']) {
$opts['version'] = $input;
}
if ($opts['version'] && version_compare($opts['version'], RCMAIL_VERSION, '>'))
if ($opts['version'] && version_compare(version_parse($opts['version']), version_parse(RCMAIL_VERSION), '>'))
die("Nothing to be done here. Bye!\n");
@ -169,7 +169,7 @@ if ($RCI->configured) {
}
// index contacts for fulltext searching
if (version_compare($opts['version'], '0.6', '<')) {
if (version_compare(version_parse($opts['version']), '0.6.0', '<')) {
system(INSTALL_PATH . 'bin/indexcontacts.sh');
}

@ -633,8 +633,8 @@ class rcube_install
*/
function update_db($DB, $version)
{
$version = strtolower($version);
$engine = isset($this->db_map[$DB->db_provider]) ? $this->db_map[$DB->db_provider] : $DB->db_provider;
$version = version_parse(strtolower($version));
$engine = isset($this->db_map[$DB->db_provider]) ? $this->db_map[$DB->db_provider] : $DB->db_provider;
// read schema file from /SQL/*
$fname = INSTALL_PATH . "SQL/$engine.update.sql";
@ -643,7 +643,7 @@ class rcube_install
foreach ($lines as $line) {
$is_comment = preg_match('/^--/', $line);
if (!$from && $is_comment && preg_match('/from version\s([0-9.]+[a-z-]*)/', $line, $m)) {
$v = strtolower($m[1]);
$v = version_parse(strtolower($m[1]));
if ($v == $version || version_compare($version, $v, '<='))
$from = true;
}

@ -357,6 +357,22 @@ function format_email($email)
}
/**
* Fix version number so it can be used correctly in version_compare()
*
* @param string $version Version number string
*
* @param return Version number string
*/
function version_parse($version)
{
return str_replace(
array('-stable', '-git'),
array('.0', '.99'),
$version);
}
/**
* mbstring replacement functions
*/

@ -207,4 +207,12 @@ class Framework_Bootstrap extends PHPUnit_Framework_TestCase
$this->assertFalse($result, "Invalid ASCII (UTF-8 character [2])");
}
/**
* bootstrap.php: version_parse()
*/
function test_version_parse()
{
$this->assertEquals('0.9.0', version_parse('0.9-stable'));
$this->assertEquals('0.9.99', version_parse('0.9-git'));
}
}

Loading…
Cancel
Save