Skip to content
Snippets Groups Projects
Commit b8cbe157 authored by Thijs Kinkhorst's avatar Thijs Kinkhorst
Browse files

Version checking: do not poll github when running master, and store result in session.

parent e8ee8c83
Branches
Tags
No related merge requests found
...@@ -70,27 +70,34 @@ $allLinks = array( ...@@ -70,27 +70,34 @@ $allLinks = array(
); );
SimpleSAML\Module::callHooks('frontpage', $allLinks); SimpleSAML\Module::callHooks('frontpage', $allLinks);
// check for updates // Check for updates. Store the remote result in the session so we
if ($config->getBoolean('admin.checkforupdates', true)) { // don't need to fetch it on every access of this page.
$api_url = 'https://api.github.com/repos/simplesamlphp/simplesamlphp/releases'; $current = $config->getVersion();
$ch = curl_init($api_url.'/latest'); if ($config->getBoolean('admin.checkforupdates', true) && $current !== 'master') {
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1); $latest = $session->getData("core:latest_simplesamlphp_version", "version");
curl_setopt($ch, CURLOPT_USERAGENT, 'SimpleSAMLphp');
curl_setopt($ch, CURLOPT_TIMEOUT, 2); if (!$latest) {
$response = curl_exec($ch); $api_url = 'https://api.github.com/repos/simplesamlphp/simplesamlphp/releases';
$ch = curl_init($api_url.'/latest');
if (curl_getinfo($ch, CURLINFO_HTTP_CODE) === 200) { curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
$latest = json_decode($response, true); curl_setopt($ch, CURLOPT_USERAGENT, 'SimpleSAMLphp');
$current = $config->getVersion(); curl_setopt($ch, CURLOPT_TIMEOUT, 2);
if ($current !== 'master' && version_compare($current, ltrim($latest['tag_name'], 'v'), 'lt')) { $response = curl_exec($ch);
$outdated = true;
$warnings[] = array( if (curl_getinfo($ch, CURLINFO_HTTP_CODE) === 200) {
'{core:frontpage:warnings_outdated}', $latest = json_decode($response, true);
array('%LATEST_URL%' => $latest['html_url']) $session->setData("core:latest_simplesamlphp_version", "version", $latest);
);
} }
curl_close($ch);
}
if ($latest && version_compare($current, ltrim($latest['tag_name'], 'v'), 'lt')) {
$outdated = true;
$warnings[] = array(
'{core:frontpage:warnings_outdated}',
array('%LATEST_URL%' => $latest['html_url'])
);
} }
curl_close($ch);
} }
$enablematrix = array( $enablematrix = array(
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment