Fix the marketplace searching when a module config file has missed fields (#6946)

This commit is contained in:
Yuriy Bakhtin 2024-04-12 08:48:03 +02:00 committed by GitHub
parent f9fc8fce7a
commit df2a089436
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
2 changed files with 12 additions and 34 deletions

View File

@ -4,6 +4,7 @@ HumHub Changelog
1.16.0-beta.3 (TBD)
-----------------------------
- Fix #5629: Legacy configuration self test not showing "OK"
- Fix #6909: Fix the marketplace searching when a module config file has missed fields
1.16.0-beta.2 (April 9, 2024)

View File

@ -69,13 +69,7 @@ class Module extends \yii\base\Module
*/
public function getName()
{
$info = $this->getModuleInfo();
if ($info['name']) {
return $info['name'];
}
return $this->id;
return $this->getModuleInfo()['name'] ?? $this->id;
}
/**
@ -85,13 +79,7 @@ class Module extends \yii\base\Module
*/
public function getDescription()
{
$info = $this->getModuleInfo();
if ($info['description']) {
return $info['description'];
}
return "";
return $this->getModuleInfo()['description'] ?? '';
}
/**
@ -101,13 +89,7 @@ class Module extends \yii\base\Module
*/
public function getVersion()
{
$info = $this->getModuleInfo();
if ($info['version']) {
return $info['version'];
}
return "1.0";
return $this->getModuleInfo()['version'] ?? '1.0';
}
/**
@ -134,13 +116,7 @@ class Module extends \yii\base\Module
*/
public function getKeywords(): array
{
$info = $this->getModuleInfo();
if ($info['keywords']) {
return (array)$info['keywords'];
}
return [];
return $this->getModuleInfo()['keywords'] ?? [];
}
/**
@ -328,15 +304,16 @@ class Module extends \yii\base\Module
*
* @return array module.json content
*/
protected function getModuleInfo()
protected function getModuleInfo(): array
{
if ($this->_moduleInfo !== null) {
return $this->_moduleInfo;
if ($this->_moduleInfo === null) {
$configPath = $this->getBasePath() . DIRECTORY_SEPARATOR . 'module.json';
$this->_moduleInfo = file_exists($configPath)
? Json::decode(file_get_contents($configPath))
: ['id' => $this->id];
}
$moduleJson = file_get_contents($this->getBasePath() . DIRECTORY_SEPARATOR . 'module.json');
return $this->_moduleInfo = Json::decode($moduleJson);
return $this->_moduleInfo;
}
/**