From 8edbc7e6cd9234399c9fdeb53dcdefc5c16dfe1e Mon Sep 17 00:00:00 2001 From: Coleman Watts Date: Fri, 12 Apr 2013 21:15:36 -0700 Subject: [PATCH] Fix version comparisons CRM-12335 --- CRM/Utils/VersionCheck.php | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) 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; } } -- 2.25.1