Skip to content

Commit

Permalink
58 - fixes Zend_Version::getLatest
Browse files Browse the repository at this point in the history
  • Loading branch information
Shardj committed Apr 1, 2020
1 parent 764ec85 commit c9b0f21
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 5 deletions.
3 changes: 2 additions & 1 deletion composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,8 @@
"homepage": "http://framework.zend.com/",
"license": "BSD-3-Clause",
"require": {
"php": ">=7.1"
"php": ">=7.1",
"ext-json": "*"
},
"autoload": {
"psr-0": {
Expand Down
19 changes: 15 additions & 4 deletions library/Zend/Version.php
Original file line number Diff line number Diff line change
Expand Up @@ -69,10 +69,21 @@ public static function getLatest()
if (null === self::$_latestVersion) {
self::$_latestVersion = 'not available';

$handle = fopen('http://framework.zend.com/api/zf-version', 'r');
if (false !== $handle) {
self::$_latestVersion = stream_get_contents($handle);
fclose($handle);
$opts = [
'http' => [
'method' => 'GET',
'header' => [
'User-Agent: PHP'
]
]
];
$context = stream_context_create($opts);
$content = file_get_contents('https://api.github.com/repos/Shardj/zf1-future/releases/latest', false, $context);

if (false !== $content) {
$releaseName = json_decode($content, true)['name'];

self::$_latestVersion = array_pop(explode('-', $releaseName));
}
}

Expand Down

0 comments on commit c9b0f21

Please sign in to comment.