diff options
author | Brian Evans <grknight@gentoo.org> | 2020-10-02 22:55:25 -0400 |
---|---|---|
committer | Brian Evans <grknight@gentoo.org> | 2020-10-02 22:55:25 -0400 |
commit | 64483be36db96f8cd9e787518b6ffa7fe81d7b37 (patch) | |
tree | 1db0888aa8cda4640c742bccdf5dc885dd722d0d | |
parent | Fix CommentStreams from blowing up (diff) | |
download | extensions-64483be36db96f8cd9e787518b6ffa7fe81d7b37.tar.gz extensions-64483be36db96f8cd9e787518b6ffa7fe81d7b37.tar.bz2 extensions-64483be36db96f8cd9e787518b6ffa7fe81d7b37.zip |
Fix GentooPackages Http request
Signed-off-by: Brian Evans <grknight@gentoo.org>
-rw-r--r-- | GentooPackages/GentooPackages.php | 14 |
1 files changed, 11 insertions, 3 deletions
diff --git a/GentooPackages/GentooPackages.php b/GentooPackages/GentooPackages.php index fe73bda4..f8ecfd79 100644 --- a/GentooPackages/GentooPackages.php +++ b/GentooPackages/GentooPackages.php @@ -14,10 +14,18 @@ class GentooPackages { static function fetchOrError($atom, $type) { global $wgVersion; + $url = "https://packages.gentoo.org/packages/${atom}.json"; if(version_compare( $wgVersion, '1.33', '<=' )) - $json_str = Http::get("https://packages.gentoo.org/packages/${atom}.json"); - else - $json_str = \MediaWiki\Http\HttpRequestFactory::get("https://packages.gentoo.org/packages/${atom}.json"); + $json_str = Http::get($url); + else { + $httpRequest = \MediaWiki\MediaWikiServices::getInstance()->getHttpRequestFactory() + ->create($url, [ 'method' => 'GET' ], __METHOD__ ); + $status = $httpRequest->execute(); + if ($status->isOK()) + $json_str = $httpRequest->getContent(); + else + $json_str = false; + } if ($json_str === false) { return '<div class="alert alert-danger">Cannot load package information. Is the atom <em>' . htmlspecialchars($atom) . '</em> correct?</div>'; |