Loading src/Helpers/Build.php +37 −2 Original line number Diff line number Diff line Loading @@ -403,6 +403,15 @@ private function parseSemVer($versionString) { $versionArray = explode(".", $versionString); if(empty($versionArray[0])) { $versionArray[0] = 0; } if(empty($versionArray[1])) { $versionArray[1] = 0; } if(empty($versionArray[2])) { $versionArray[2] = 0; } return array_map("intval", $versionArray); } Loading Loading @@ -532,9 +541,9 @@ * @param type $params The params dictionary inside the current POST request * @return boolean True if valid, False if not. */ public function includeInResults($params) public function includeInResults($params, $currenteOSVersion) { return $this->isValid($params) && $this->checkRollout() && $this->getSize() > 0; return $this->isValid($params) && $this->checkRollout() && $this->checkRequirements($currenteOSVersion) && $this->getSize() > 0; } /** Loading @@ -555,10 +564,36 @@ return ($configFilePath) ? json_decode( file_get_contents($configFilePath) , true) : array(); } /** * Return if requirements are met or not for a build * @return boolean */ public function checkRequirements($currenteOSVersion="") { $minimalVersion = isset($this->confProp['requirements']) ? $this->confProp['requirements']['minOSVersion'] : null; $isCompatible = true; if(isset($minimalVersion)){ $currenteOSVersionSemantic = $this->parseSemVer($currenteOSVersion); $minimalSemanticVersion = $this->parseSemVer($minimalVersion); $isCompatible = false; if($currenteOSVersionSemantic[0] == $minimalSemanticVersion[0]){ if($currenteOSVersionSemantic[1] == $minimalSemanticVersion[1]){ $isCompatible = $currenteOSVersionSemantic[2] >= $minimalSemanticVersion[2]; } else $isCompatible = $currenteOSVersionSemantic[1] > $minimalSemanticVersion[1]; } else $isCompatible = $currenteOSVersionSemantic[0] > $minimalSemanticVersion[0]; } return $isCompatible; } /** * Return if rollout successful or not for a build * @return boolean */ public function checkRollout() { $rolloutpercentage = isset($this->confProp['rollout']['percentage']) ? (int) $this->confProp['rollout']['percentage'] : 100; Loading src/Helpers/Builds.php +2 −1 Original line number Diff line number Diff line Loading @@ -162,6 +162,7 @@ $params = $this->postData['params']; preg_match_all('/.*(eOS) v([0-9\.]+)-?((alpha|beta|rc)(\.\d)?)?.*/', $_SERVER['HTTP_USER_AGENT'], $currentTokens); $shouldDisplayPatch=false; $this->currenteOSVersion = -1; if(isset($currentTokens[2]) && count($currentTokens[2])>0){ $this->currenteOSVersion = $currentTokens[2][0]; $versionArray = explode(".", $this->currenteOSVersion); Loading Loading @@ -204,7 +205,7 @@ $build = new Build($file, $dir, $this->logger, $shouldDisplayPatch); } if ($build->includeInResults($this->postData['params'])) { if ($build->includeInResults($this->postData['params'], $this->currenteOSVersion)) { array_push($this->builds, $build); } Loading Loading
src/Helpers/Build.php +37 −2 Original line number Diff line number Diff line Loading @@ -403,6 +403,15 @@ private function parseSemVer($versionString) { $versionArray = explode(".", $versionString); if(empty($versionArray[0])) { $versionArray[0] = 0; } if(empty($versionArray[1])) { $versionArray[1] = 0; } if(empty($versionArray[2])) { $versionArray[2] = 0; } return array_map("intval", $versionArray); } Loading Loading @@ -532,9 +541,9 @@ * @param type $params The params dictionary inside the current POST request * @return boolean True if valid, False if not. */ public function includeInResults($params) public function includeInResults($params, $currenteOSVersion) { return $this->isValid($params) && $this->checkRollout() && $this->getSize() > 0; return $this->isValid($params) && $this->checkRollout() && $this->checkRequirements($currenteOSVersion) && $this->getSize() > 0; } /** Loading @@ -555,10 +564,36 @@ return ($configFilePath) ? json_decode( file_get_contents($configFilePath) , true) : array(); } /** * Return if requirements are met or not for a build * @return boolean */ public function checkRequirements($currenteOSVersion="") { $minimalVersion = isset($this->confProp['requirements']) ? $this->confProp['requirements']['minOSVersion'] : null; $isCompatible = true; if(isset($minimalVersion)){ $currenteOSVersionSemantic = $this->parseSemVer($currenteOSVersion); $minimalSemanticVersion = $this->parseSemVer($minimalVersion); $isCompatible = false; if($currenteOSVersionSemantic[0] == $minimalSemanticVersion[0]){ if($currenteOSVersionSemantic[1] == $minimalSemanticVersion[1]){ $isCompatible = $currenteOSVersionSemantic[2] >= $minimalSemanticVersion[2]; } else $isCompatible = $currenteOSVersionSemantic[1] > $minimalSemanticVersion[1]; } else $isCompatible = $currenteOSVersionSemantic[0] > $minimalSemanticVersion[0]; } return $isCompatible; } /** * Return if rollout successful or not for a build * @return boolean */ public function checkRollout() { $rolloutpercentage = isset($this->confProp['rollout']['percentage']) ? (int) $this->confProp['rollout']['percentage'] : 100; Loading
src/Helpers/Builds.php +2 −1 Original line number Diff line number Diff line Loading @@ -162,6 +162,7 @@ $params = $this->postData['params']; preg_match_all('/.*(eOS) v([0-9\.]+)-?((alpha|beta|rc)(\.\d)?)?.*/', $_SERVER['HTTP_USER_AGENT'], $currentTokens); $shouldDisplayPatch=false; $this->currenteOSVersion = -1; if(isset($currentTokens[2]) && count($currentTokens[2])>0){ $this->currenteOSVersion = $currentTokens[2][0]; $versionArray = explode(".", $this->currenteOSVersion); Loading Loading @@ -204,7 +205,7 @@ $build = new Build($file, $dir, $this->logger, $shouldDisplayPatch); } if ($build->includeInResults($this->postData['params'])) { if ($build->includeInResults($this->postData['params'], $this->currenteOSVersion)) { array_push($this->builds, $build); } Loading