Merge pull request #115 from radiorabe/fix/version-comparison-code

Make version comparision robust
This commit is contained in:
Robb 2017-03-23 08:55:12 -04:00 committed by GitHub
commit e6e0840bf2

View file

@ -23,11 +23,14 @@ class Airtime_View_Helper_VersionNotify extends Zend_View_Helper_Abstract {
$latest = Application_Model_Preference::GetLatestVersion();
$link = Application_Model_Preference::GetLatestLink();
$isGitRelease = preg_match('/^[[:alnum:]]{7}$/i', $current) === 1;
$currentParts = array(0, 0, 0, 0);
$isGitRelease = preg_match('/^[[:alnum:]]{7,}$/i', $current) === 1;
$currentParts = array();
if (!$isGitRelease) {
$currentParts = preg_split("/(\.|-)/", $current);
}
if (count($currentParts) < 3) {
$currentParts = array(0, 0, 0, 0);
}
$majorCandidates = SemVer::satisfiedBy($latest, sprintf('>=%1$s', $currentParts[0] + 1));
$minorCandidates = SemVer::satisfiedBy($latest, sprintf('~%1$s.%2$s', $currentParts[0], $currentParts[1] + 1));