@@ -1679,7 +1679,11 @@ public function getAllowedLanguagesForContest(?Contest $contest) : array {
16791679 public function checkNewVersion (): string |false {
16801680 if (!$ this ->config ->get ('check_new_version ' )) {
16811681 return false ;
1682- }
1682+ }
1683+ $ patch = "/ " . substr ($ this ->domjudgeVersion , 0 , strrpos ($ this ->domjudgeVersion , '. ' )) . ".\d/ " ;
1684+ $ minor = "/ " . substr ($ this ->domjudgeVersion , 0 , strpos ($ this ->domjudgeVersion , '. ' )) . ".\d.\d/ " ;
1685+ $ major = "/\d.\d.\d/ " ;
1686+
16831687 $ versionLocalString = explode ("/ " , str_replace ("DEV " , "-prerelease " , $ this ->domjudgeVersion ))[0 ];
16841688 $ versionLocal = Version::parse ($ versionLocalString , false );
16851689 $ versionUrl = 'https://versions.domjudge.org ' ;
@@ -1695,38 +1699,18 @@ public function checkNewVersion(): string|false {
16951699 * otherwise the latest minor, or Major release. So the user might make the upgrade path:
16961700 * DJ6.0.0 -> DJ6.0.6 -> DJ6.6.0 -> DJ9.0.0 instead of
16971701 * -> DJ6.0.[1..6] -> DJ6.[1..6] -> DJ[7..9].0.0
1698- */
1699- $ latestPatchString = $ versionLocal ;
1700- if (isset ($ versions [$ versionLocal ->getMajor ()][$ versionLocal ->getMinor ()])) {
1701- $ latestPatchString = Version::rsortString ($ versions [$ versionLocal ->getMajor ()][$ versionLocal ->getMinor ()])[0 ];
1702- $ latestPatch = Version::parse ($ latestPatchString );
1703- if (Version::compare ($ versionLocal , $ latestPatch ) < 0 ) {
1704- return $ latestPatchString ;
1705- }
1706- }
1707- $ latestMinorString = $ versionLocal ;
1708- if (isset ($ versions [$ versionLocal ->getMajor ()])) {
1709- $ highestMinorInMajor = array_keys ($ versions [$ versionLocal ->getMajor ()]);
1710- rsort ($ highestMinorInMajor );
1711- $ latestMinorString = Version::rsortString ($ versions [$ versionLocal ->getMajor ()][$ highestMinorInMajor [0 ]])[0 ];
1712- $ latestMinor = Version::parse ($ latestMinorString );
1713- if (Version::compare ($ versionLocal , $ latestMinor ) < 0 ) {
1714- return $ latestMinorString ;
1702+ */
1703+ $ newer_releases = [];
1704+ foreach ([$ patch , $ minor , $ major ] as $ regex ) {
1705+ foreach ($ versions as $ release ) {
1706+ if (preg_match ($ regex , $ release )) {
1707+ $ newer_releases [] = $ release ;
1708+ }
17151709 }
1716- }
1717- $ latestMajorString = $ versionLocal ;
1718- try {
1719- $ highestMajor = array_keys ($ versions );
1720- rsort ($ highestMajor );
1721- $ highestMinorInMajor = array_keys ($ versions [$ highestMajor [0 ]]);
1722- rsort ($ highestMinorInMajor );
1723- $ latestMajorString = Version::rsortString ($ versions [$ highestMajor [0 ]][$ highestMinorInMajor [0 ]])[0 ];
1724- $ latestMajor = Version::parse ($ latestMajorString );
1725- if (Version::compare ($ versionLocal , $ latestMajor ) < 0 ) {
1726- return $ latestMajorString ;
1710+ if (count ($ newer_releases ) > 0 ) {
1711+ natsort ($ newer_releases );
1712+ return end ($ newer_releases );
17271713 }
1728- } catch (Exception $ e ) {
1729- return false ;
17301714 }
17311715 return false ;
17321716 }
0 commit comments