Skip to content

Commit

Permalink
Release 2.1.10
Browse files Browse the repository at this point in the history
  • Loading branch information
luke- committed Apr 13, 2022
1 parent dc3e262 commit 1220515
Show file tree
Hide file tree
Showing 2 changed files with 33 additions and 12 deletions.
5 changes: 3 additions & 2 deletions docs/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,9 +1,10 @@
Changelog
=========

2.1.10 (Unreleased)
--------------------------
2.1.10 (April 13, 2022)
------------------------
- Enh #24: Show current update channel with link to module configuration
- Enh: Removed Zend HTTP requirement

2.1.9 (February 5, 2021)
--------------------------
Expand Down
40 changes: 30 additions & 10 deletions libs/AvailableUpdate.php
Original file line number Diff line number Diff line change
Expand Up @@ -37,16 +37,36 @@ public function download()
// Download Package
if (!is_file($targetFile)) {
try {
$http = new \Zend\Http\Client($this->downloadUrl, array(
'adapter' => '\Zend\Http\Client\Adapter\Curl',
'curloptions' => Yii::$app->getModule('updater')->getCurlOptions(),
'timeout' => 300
));
$http->setStream();
$response = $http->send();
copy($response->getStreamName(), $targetFile);
} catch (Exception $ex) {
throw new Exception(Yii::t('UpdaterModule.libs_UpdatePackage', 'Update download failed! (%error%)', array('%error%' => $ex->getMessage())));
if (class_exists('\yii\httpclient\Client')) {
$fh = fopen($targetFile, 'w');
$client = new \yii\httpclient\Client([
'transport' => 'yii\httpclient\CurlTransport'
]);
$response = $client->createRequest()
->setMethod('GET')
->setUrl($this->downloadUrl)
->setOutputFile($fh)
->setOptions(Yii::$app->getModule('updater')->getCurlOptions())
->send();

if (!$response->isOk) {
Yii::error('Could not download upgrade package: ' . $response->getStatusCode());
throw new \Exception('Download Response is not ok!');
}
} else {
// Older Versions
$http = new \Zend\Http\Client($this->downloadUrl, array(
'adapter' => '\Zend\Http\Client\Adapter\Curl',
'curloptions' => Yii::$app->getModule('updater')->getCurlOptions(),
'timeout' => 300
));
$http->setStream();
$response = $http->send();
copy($response->getStreamName(), $targetFile);
}

} catch (\Exception $ex) {
throw new \Exception(Yii::t('UpdaterModule.libs_UpdatePackage', 'Update download failed! (%error%)', array('%error%' => $ex->getMessage())));
}
}

Expand Down

0 comments on commit 1220515

Please sign in to comment.