I played around with the git api and found a way to retrieve a complete list of all available zipballs from the latest one down to v2.2.0-pl2:
curl -i https://api.github.com/repos/modxcms/revolution/tags
@sottwell I've downloaded the latest zipball and it is NOT identical to the pl installation package
The tags seem to be sorted in a way that we can use to extract the latest version.
[
{
"name": "v2.3.3-pl",
"zipball_url": "https://api.github.com/repos/modxcms/revolution/zipball/v2.3.3-pl",
"tarball_url": "https://api.github.com/repos/modxcms/revolution/tarball/v2.3.3-pl",
"commit": {
"sha": "b754e6e619837bd41c7c4e2ba6ecacb67e6732a4",
"url": "https://api.github.com/repos/modxcms/revolution/commits/b754e6e619837bd41c7c4e2ba6ecacb67e6732a4"
}
},
...
]
Comparing it against the system setting should tell us what we want to know:
<?php
$url = "https://api.github.com/repos/modxcms/revolution/tags";
$user_agent = 'revolution';
function get_content_from_github($url,$user_agent) {
$ch = curl_init();
curl_setopt($ch,CURLOPT_URL,$url);
curl_setopt($ch,CURLOPT_RETURNTRANSFER,1);
curl_setopt($ch,CURLOPT_CONNECTTIMEOUT,1);
curl_setopt($ch,CURLOPT_USERAGENT,$user_agent);
$content = curl_exec($ch);
curl_close($ch);
return $content;
}
$tags = get_content_from_github($url,$user_agent);
$tags = json_decode($tags);
$latest = get_object_vars($tags[0]);
$latest = trim ($latest['name'], 'v.'); //v2.3.3-pl.
$version = $modx->getOption('settings_version'); //2.3.3-pl
if($latest == $version){
return "Your MODX setup is up-to-date ($version)";
}
else{
return "You should update from ".$version." to ".$latest;
}
Don't know how clever it is to rely on the sort order of the tags json, but it seems to do the job.
Cheers,
pepebe
[ed. note: pepebe last edited this post 9 years, 2 months ago.]