From: Coleman Watts Date: Sat, 13 Apr 2013 04:15:36 +0000 (-0700) Subject: Fix version comparisons CRM-12335 X-Git-Url: https://vcs.fsf.org/?a=commitdiff_plain;h=8edbc7e6cd9234399c9fdeb53dcdefc5c16dfe1e;p=civicrm-core.git Fix version comparisons CRM-12335 --- diff --git a/CRM/Utils/VersionCheck.php b/CRM/Utils/VersionCheck.php index b6a7e1e0e1..0dde6a4939 100644 --- a/CRM/Utils/VersionCheck.php +++ b/CRM/Utils/VersionCheck.php @@ -90,7 +90,7 @@ class CRM_Utils_VersionCheck { require_once ($localfile); if (function_exists('civicrmVersion')) { $info = civicrmVersion(); - $this->localVersion = $info['version']; + $this->localVersion = trim($info['version']); } } if ($config->versionCheck) { @@ -99,7 +99,7 @@ class CRM_Utils_VersionCheck { // if there's a cachefile and it's not stale use it to // read the latestVersion, else read it from the Internet if (file_exists($cachefile) && (filemtime($cachefile) > $expiryTime)) { - $this->latestVersion = file_get_contents($cachefile); + $this->latestVersion = trim(file_get_contents($cachefile)); } else { $siteKey = md5(defined('CIVICRM_SITE_KEY') ? CIVICRM_SITE_KEY : ''); @@ -168,10 +168,12 @@ class CRM_Utils_VersionCheck { $latest = array_pad(explode('.', $this->latestVersion), 3, 0); for ($i = 0; $i < 3; $i++) { - if ($local[$i] > $latest[$i]) { + $loc = (int) $local[$i]; + $lat = (int) $latest[$i]; + if ($loc > $lat) { return NULL; } - elseif ($local[$i] < $latest[$i]) { + elseif ($loc < $lat) { return $this->latestVersion; } }