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) 1.16.0-beta.3 (TBD)
----------------------------- -----------------------------
- Fix #5629: Legacy configuration self test not showing "OK" - 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) 1.16.0-beta.2 (April 9, 2024)

View File

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