diff --git a/docs/CHANGELOG.md b/docs/CHANGELOG.md index e7abd7a..b604abb 100644 --- a/docs/CHANGELOG.md +++ b/docs/CHANGELOG.md @@ -1,5 +1,8 @@ Changelog ========= +## TBA +- Fix #49: module update with error logged when module is inactive + ## 1.0.5 (23/1/2024) - Fix #47: wrong message category of save button diff --git a/models/Config.php b/models/Config.php index a2398ac..d7e6585 100644 --- a/models/Config.php +++ b/models/Config.php @@ -16,17 +16,18 @@ class Config extends \yii\base\Model public $theme; - public $showButton; + public $showButton = true; public function init() { parent::init(); - $settings = Yii::$app->getModule('dark-mode')->settings; - - $this->theme = $settings->get('theme'); - - $this->showButton = $settings->get('showButton', true); + $module = Yii::$app->getModule('dark-mode'); + // make sure module is enabled before retrieving settings, see https://github.com/felixhahnweilheim/humhub-dark-mode/issues/48 + if ($module) { + $this->theme = $module->settings->get('theme'); + $this->showButton = $module->settings->get('showButton', $this->showButton); + } // If no setting was found, get recommended theme or fallback (DarkHumHub) if (empty($this->theme)) {