Skip to content

Remove compatibility stuff not required for minVersion #39

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
35 changes: 1 addition & 34 deletions Module.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@

namespace humhub\modules\updater;

use humhub\models\Setting;
use humhub\modules\updater\models\ConfigureForm;
use Yii;
use yii\base\Exception;
Expand All @@ -23,7 +22,7 @@ public function getConfigUrl()
/**
* Returns the temp path of updater
*
* @return type
* @return string
*/
public static function getTempPath()
{
Expand All @@ -42,38 +41,6 @@ public static function getTempPath()
return $path;
}

public function getCurlOptions()
{
// Compatiblity for older versions
if (!class_exists('humhub\libs\CURLHelper')) {
$options = array(
CURLOPT_SSL_VERIFYPEER => (Yii::$app->getModule('admin')->marketplaceApiValidateSsl) ? true : false,
CURLOPT_SSL_VERIFYHOST => (Yii::$app->getModule('admin')->marketplaceApiValidateSsl) ? 2 : 0,
CURLOPT_REDIR_PROTOCOLS => CURLPROTO_HTTP | CURLPROTO_HTTPS,
CURLOPT_PROTOCOLS => CURLPROTO_HTTP | CURLPROTO_HTTPS,
CURLOPT_CAINFO => Yii::getAlias('@humhub/config/cacert.pem')
);

if (Setting::Get('enabled', 'proxy')) {
$options[CURLOPT_PROXY] = Setting::Get('server', 'proxy');
$options[CURLOPT_PROXYPORT] = Setting::Get('port', 'proxy');
if (defined('CURLOPT_PROXYUSERNAME')) {
$options[CURLOPT_PROXYUSERNAME] = Setting::Get('user', 'proxy');
}
if (defined('CURLOPT_PROXYPASSWORD')) {
$options[CURLOPT_PROXYPASSWORD] = Setting::Get('pass', 'proxy');
}
if (defined('CURLOPT_NOPROXY')) {
$options[CURLOPT_NOPROXY] = Setting::Get('noproxy', 'proxy');
}
}

return $options;
}

return \humhub\libs\CURLHelper::getOptions();
}

/**
* Get current update channel value
*
Expand Down
24 changes: 4 additions & 20 deletions controllers/UpdateController.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
namespace humhub\modules\updater\controllers;

use humhub\modules\admin\components\Controller;
use humhub\modules\marketplace\components\OnlineModuleManager;
use humhub\modules\updater\libs\OnlineUpdateAPI;
use Yii;

Expand All @@ -17,14 +18,6 @@ class UpdateController extends Controller
public function init()
{
set_time_limit(0);

// Fix: Handle admin layout file change in (v1.0.0-beta.3 -> v1.0.0-beta.4)
if ($this->subLayout == '@humhub/modules/admin/views/_layout') {
if (!file_exists(Yii::getAlias($this->subLayout) . '.php')) {
$this->subLayout = '@humhub/modules/admin/views/layouts/main';
}
}

parent::init();
}

Expand Down Expand Up @@ -86,18 +79,9 @@ public function actionDownload()
protected function isNewUpdaterModuleAvailable()
{
Yii::$app->cache->flush();
$modules = null;

if (class_exists('\humhub\modules\admin\libs\OnlineModuleManager')) {
$onlineModuleManager = new \humhub\modules\admin\libs\OnlineModuleManager();
$modules = $onlineModuleManager->getModuleUpdates();
} elseif (class_exists('\humhub\modules\marketplace\libs\OnlineModuleManager')) {
$onlineModuleManager = new \humhub\modules\marketplace\libs\OnlineModuleManager();
$modules = $onlineModuleManager->getModuleUpdates();
} elseif (class_exists('\humhub\modules\marketplace\components\OnlineModuleManager')) {
$onlineModuleManager = new \humhub\modules\marketplace\components\OnlineModuleManager();
$modules = $onlineModuleManager->getModuleUpdates();
}

$onlineModuleManager = new OnlineModuleManager();
$modules = $onlineModuleManager->getModuleUpdates();

if (isset($modules['updater'])) {
return true;
Expand Down
1 change: 1 addition & 0 deletions docs/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ Changelog
- Enh #29: Remove deprecated "Setting" classes
- Fix #36: Fix URL to available updates on Marketplace
- Fix #38: Remove deprecated class `humhub\widgets\MarkdownView`
- Enh #37: Remove compatibility stuff not required for `minVersion`

2.1.12 (April 26, 2022)
------------------------
Expand Down
39 changes: 13 additions & 26 deletions libs/AvailableUpdate.php
Original file line number Diff line number Diff line change
Expand Up @@ -37,34 +37,21 @@ public function download()
// Download Package
if (!is_file($targetFile)) {
try {
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();
$fh = fopen($targetFile, 'w');
$client = new \yii\httpclient\Client([
'transport' => 'yii\httpclient\CurlTransport'
]);
$response = $client->createRequest()
->setMethod('GET')
->setUrl($this->downloadUrl)
->setOutputFile($fh)
->setOptions(\humhub\libs\CURLHelper::getOptions())
->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);
if (!$response->isOk) {
Yii::error('Could not download upgrade package: ' . $response->getStatusCode());
throw new \Exception('Download Response is not ok!');
}

} catch (\Exception $ex) {
throw new \Exception(Yii::t('UpdaterModule.libs_UpdatePackage', 'Update download failed! (%error%)', array('%error%' => $ex->getMessage())));
}
Expand Down
13 changes: 4 additions & 9 deletions modules/packageinstaller/controllers/InstallController.php
Original file line number Diff line number Diff line change
Expand Up @@ -110,16 +110,11 @@ public function actionCleanup()

protected function switchToDefaultTheme()
{
if (version_compare(Yii::$app->version, '1.1', '<')) {
\humhub\models\Setting::Set('theme', 'HumHub');
} elseif (version_compare(Yii::$app->version, '1.3.7', '<')) {
Yii::$app->settings->set('theme', 'HumHub');
} else {
$theme = \humhub\modules\ui\view\helpers\ThemeHelper::getThemeByName('HumHub');
if ($theme !== null) {
$theme->activate();
}
$theme = \humhub\modules\ui\view\helpers\ThemeHelper::getThemeByName('HumHub');
if ($theme !== null) {
$theme->activate();
}

\humhub\libs\DynamicConfig::rewrite();
}

Expand Down
10 changes: 1 addition & 9 deletions views/update/start.php
Original file line number Diff line number Diff line change
Expand Up @@ -61,15 +61,7 @@
</div>
</div>


<?php
$nonce = '';
if (version_compare(Yii::$app->version, '1.4', '>')) {
$nonce = Html::nonce();
}
?>

<script <?= $nonce; ?>>
<script <?= Html::nonce() ?>>
$('#errorMessageBox').hide();
$('#successMessageBox').hide();

Expand Down