Enh #5100: Added SelfTest for HumHub API connectivity

This commit is contained in:
Lucas Bartholemy 2022-11-09 11:31:26 +01:00
parent 02db2d5af8
commit 491770b35c
3 changed files with 19 additions and 3 deletions

View File

@ -15,3 +15,4 @@ HumHub Changelog
- Fix #5903: ContentContainerModule::getEnabledContentContainers() returns an empty array
- Enh #5908: New filter ActiveQueryUser->available()
- Enh #5785: Adding option for custom .well-known routes
- Enh #5100: Added SelfTest for HumHub API connectivity

View File

@ -8,6 +8,7 @@
namespace humhub\libs;
use humhub\modules\admin\libs\HumHubAPI;
use humhub\modules\ldap\helpers\LdapHelper;
use humhub\modules\marketplace\Module;
use Yii;
@ -541,7 +542,7 @@ class SelfTest
'hint' => Yii::t('AdminModule.information', 'Make {filePath} writable for the Webserver/PHP!', ['filePath' => $path])
];
}
// Check Custom Modules Directory
// Check Dynamic Config is Writable
$title = Yii::t('AdminModule.information', 'Permissions') . ' - ' . Yii::t('AdminModule.information', 'Dynamic Config');
$path = Yii::getAlias(Yii::$app->params['dynamicConfigFile']);
if (!is_file($path)) {
@ -561,6 +562,20 @@ class SelfTest
];
}
// Check HumHub Marketplace API Connection
$title = Yii::t('AdminModule.information', 'HumHub') . ' - ' . Yii::t('AdminModule.information', 'Marketplace API Connection');
if (empty(HumHubAPI::getLatestHumHubVersion(false))) {
$checks[] = [
'title' => $title,
'state' => 'WARNING'
];
} else {
$checks[] = [
'title' => $title,
'state' => 'OK'
];
}
return $checks;
}

View File

@ -51,10 +51,10 @@ class HumHubAPI
*
* @return string latest HumHub Version
*/
public static function getLatestHumHubVersion()
public static function getLatestHumHubVersion($useCache = true)
{
$latestVersion = Yii::$app->cache->get('latestVersion');
if ($latestVersion === false) {
if (!$useCache || $latestVersion === false) {
$info = self::request('v1/modules/getLatestVersion');
if (isset($info['latestVersion'])) {