From 2be1e4fc6bee6140da91a50a8848374041258fda Mon Sep 17 00:00:00 2001 From: Coleman Watts Date: Tue, 23 Apr 2013 21:01:34 -0700 Subject: [PATCH] Use php version_compare function instead of our own --- CRM/Utils/VersionCheck.php | 19 ++++++------------- 1 file changed, 6 insertions(+), 13 deletions(-) diff --git a/CRM/Utils/VersionCheck.php b/CRM/Utils/VersionCheck.php index a118af2031..0f6404d756 100644 --- a/CRM/Utils/VersionCheck.php +++ b/CRM/Utils/VersionCheck.php @@ -161,22 +161,12 @@ class CRM_Utils_VersionCheck { * Get the latest version number if it's newer than the local one * * @return string|null - * Returns the newer version's number or null if the versions are equal + * Returns the newer version's number, or null if the versions are equal */ public function newerVersion() { if ($this->latestVersion) { - $local = array_pad(explode('.', $this->localVersion), 3, 0); - $latest = array_pad(explode('.', $this->latestVersion), 3, 0); - - for ($i = 0; $i < 3; $i++) { - $loc = (int) $local[$i]; - $lat = (int) $latest[$i]; - if ($loc > $lat) { - return NULL; - } - elseif ($loc < $lat) { - return $this->latestVersion; - } + if (version_compare($this->localVersion, $this->latestVersion) < 0) { + return $this->latestVersion; } } return NULL; @@ -304,6 +294,9 @@ class CRM_Utils_VersionCheck { if (!preg_match('/^\d+\.\d+\.\d+$/', $this->latestVersion)) { $this->latestVersion = NULL; } + else { + $this->latestVersion = trim($this->latestVersion); + } ini_restore('default_socket_timeout'); } -- 2.25.1